Wednesday, March 4, 2009

Installing mySql on ubuntu

To install mySql on ubuntu, type the following command on the terminal window
sudo apt-get install mysql-server
To create a new database, type the following mysqladmin command:

mysqladmin create -uroot -p

If you are running PHP you will have to install the php module:
sudo apt-get install php5-mysql

If you want to give Root user logon permissions from any host computer on the network, you will need to update the mysql user table, using the % wildcard. Type the command on the terminal to open the command-line mysql client on the server using the root account.
mysql -uroot -p

to see what the root user host has permissions for, type,
use mysql;
select host, user from user;

mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> select host, user from user;
+-------------+--------------------------+
| host | user |
+-------------+--------------------------+
| 127.0.0.1 | root |
| localhost| |
| localhost| debian-sys-maint |
| localhost| root |
| ubuntu | |
| ubuntu | root |
+-------------+--------------------------+
6 rows in set (0.00 sec)

to update the ubuntu host to use the wildcard, and then issue the command to reload the privilege tables, type,
mysql> update user set host='%' where user='root' and host='ubuntu';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

Now its possible to connect to the server from any other computer on the network, using the root user account. Doing this has some secure issues, beware to set a password for the root user accont.



0 comments: