Tuesday, 1 March 2011

Installing MySQL on Solaris (Part 4 - Initializing the Database)

Once you've installed MySQL, the next step is to create your database and get the whole thing running. To do this:

1. Change the operating user from root to mysql by typing:


su mysql

2. Change the working directory to /opt/mysql/mysql/scripts by typing:

cd /opt/mysql/mysql/scripts

3. Execute the mysql_db_install script by typing:

./mysql_install_db --user=mysql --ldata=/export/home/mysql_data

Then ensure that all the file permissions are set to the mysql user

chown -R mysql:mysql /export/home/mysql_data

4. Change the working directory to /opt/mysql/mysql/bin

cd  /opt/mysql/mysql/bin

5. Start the database by typing:

./mysqld_safe --datadir=/opt/mysql/mysql/data --user=mysql &

Or you can run the mysql as a daemon:

/etc/init.d/mysql start

(or conversely stop)

Connecting to MySQL

Try to connect to the MySQL database by typing "mysql" as the root user. You should be able to see the "mysql>" prompt for the successful connection. The only user which could connect to the database now is the root user and it doesn't require a password. For more information on user account management, visit http://dev.mysql.com/doc/refman/5.0/en/user-account-management.html.

No comments: