Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't open and lock privilege tables: Table 'mysql.user' doesn't exist

I installed MySQL community server 5.7.10 using binary zip. I extracted the zip in c:\mysql and created the data folder in c:\mysql\data. I created the config file as my.ini and placed it in c:\mysql (root folder of extracted zip). Below is the content of the my.ini file

# set basedir to your installation path basedir=C:\mysql # set datadir to the location of your data directory datadir=C:\mysql\data 

I'm trying to start MySQL using mysqld --console, but the process is aborted with the below error.

2015-12-29T18:04:01.141930Z 0 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist 2015-12-29T18:04:01.141930Z 0 [ERROR] Aborting  

Any help on this will be appreciated.

like image 399
BValluri Avatar asked Dec 29 '15 18:12

BValluri


2 Answers

You have to initialize the data directory by running the following command

mysqld --initialize [with random root password]

mysqld --initialize-insecure [with blank root password]

like image 104
anonymous Avatar answered Oct 22 '22 20:10

anonymous


The mysql_install_db script also needs the datadir parameter:

mysql_install_db --user=root --datadir=$db_datapath 

On Maria DB you use the install script mysql_install_db to install and initialize. In my case I use an environment variable for the data path. Not only does mysqld need to know where the data is (specified via commandline), but so does the install script.

like image 43
Charlie Avatar answered Oct 22 '22 21:10

Charlie