Logged in as: Guest | Login/Register
 

Initializing MySQL database after installation

Tutorials > Database Management Systems > MySQL > Configuration > Initializing MySQL database after installation

Discuss this tutorial here | Search www.geeksww.com for more tutorials here

Please read whole tutorial before doing anything. These commands were tested on a Linux environment (running MySQL 4.1.22) and should work on most Unix machines too. However, they will have to be modified a little for Windows environment.

If you have an empty data folder or you want to initialize/reinitialize MySQL server from scratch (possibly after dropping all existing databases) then use the following instructions (assuming you have root access or you can use sudo):

For this tutorial, I'll assume the data directory (where all the data was stored or has to be stored) is: /clients/example/mysql/data/. Now, execute the following commands from shell command line.

Replace data directory path with your own (will delete all your data, so think twice before you run the command):

sudo rm -drf /clients/example/mysql/data

Recreate data directory:

sudo mkdir /clients/example/mysql/data

If you are running MySQL as mysql user then do the following (replace mysql with your user name and group name):

sudo chown mysql:mysql /clients/example/mysql/data

If you have logging of any type enabled then you can also use the above commands (or slightly modify them) to delete, recreate, and assign proper privileges to them.

Now, run the MySQL installation script as follows (from inside the MySQL installation folder e.g. /opt/mysql/). Replace with your data directory path.

sudo ./scripts/mysql_install_db --user=mysql --datadir=/clients/example/mysql/data/

You should also give ownership to mysql user and group using the following command.

sudo find /clients/example/mysql/ -type d | sudo xargs chown mysql:mysql

That's it. Now, you can run your MySQL daemon using mysqld directly or using mysqld_safe (recommended).



 
Discuss this tutorial here | Search www.geeksww.com for more tutorials here
 

Similar Tutorials:

 

Support Geeks Worldwide:

Link to us:

You can support us by putting a link to our website on your blog or website (code is below).

<a href="http://www.geeksww.com/">
Geeks Worldwide - Tutorials about Software Installation,
Configuration, Administration, Monitoring, Tools, Tips &
Tricks
</a>

OR a simple one.

<a href="http://www.geeksww.com/">
Geeks Worldwide - IT related Tutorials
</a>

Feedbacks:

We appreciate feedbacks and suggestions about our tutorials and Geeks Worldwide from readers. Please contact us using the form here and let us know what you think about the tutorial and the website in general.

Bookmark Us:

We are working on new features for the website, please keep visiting or bookmark us using your favourite bookmarking service.

Subscribe to RSS:

You can subscribe to our RSS feed here.

 
Creative Commons License