1. Delete mysql
1 sudo apt-get autoremove -- purge mysql-server-5.0
2 sudo apt-get remove mysql-server
3 sudo apt-get autoremove mysql-server
4 sudo apt-get remove mysql-common (very important)
In fact, some of the above are redundant. We recommend that you execute them in sequence.
Clean residual data
Dpkg-l | grep ^ rc | awk '{print $2}' | sudo xargs dpkg-P
2. Install mysql
1 sudo apt-get install mysql-server
2 sudo apt-get install mysql-client
3 sudo apt-get install php5-mysql (installation php5-mysql is to connect php and mysql)
Once the installation is complete, the MySQL server should be started automatically. You can run the following command at a terminal prompt to check whether the MySQL server is running:
1 sudo netstat-tap | grep mysql
When you run this command, you can see a line similar to the following:
Tcp 0 0 localhost. localdomain: mysql *: * LISTEN-
If the server cannot run properly, run the following command to start it:
1 sudo/etc/init. d/mysql restart
3. Enter mysql
$ Mysql-uroot-p administrator password
Configure the MySQL administrator password:
1 sudo mysqladmin-u root password newpassword
From: blog of mac. zhao