Turn: http://blog.csdn.net/skylinethj/article/details/38524629 ubuntu12.04 install and uninstall MySQL
For an article on authorization, see http://blog.csdn.net/id19870510/article/details/8434421.
===================================================================
1: Log in the system, preferably before installation,
[HTML]View Plaincopy
- Apt-get Update
Otherwise, you may not find the installation file error prompt
2: Install MySQL server and client
[HTML]View Plaincopy
- Apt-get Install Mysql-server mysql-client
You will be prompted to enter the root password during installation.
3: Default MySQL cannot be accessed remotely after installation is complete
[HTML]View Plaincopy
- Vi/etc/mysql/my.cnf
[HTML]View Plaincopy
- Comment out bind-address = 127.0.0.1
4: Log in to MySQL with root and add the user with the grant command, such as:
[HTML]View Plaincopy
- MySQL> Grant all privileges on requires access to the db.* to [email protected] '% ' identified by ' password '; For security, don't use root in the code.
The first type:
Add a user test1 password to ABC so that he can log on on any host and have access to queries, insertions, modifications, and deletions to all databases. First, use the root user to connect to MySQL, and then type the following command:
MySQL>grant select,insert,update,delete on * * to [e-mail protected] '% ' identified by ' ABC ';
Or
MySQL>grant all privileges on * * to [e-mail protected] '% ' identified by ' ABC ';
But the increase of the user is very dangerous, you want to like someone knows test1 password, then he can be on any computer on the Internet to log on to your MySQL database and to your data can do whatever you like, the solution see the second kind of example:
The first kind: Add a user test2 password for ABC, so that he can only login on localhost, and can query, insert, modify, delete the database mydb (localhost refers to the local host, that is, the MySQL database host), This allows the user to use a password that knows test2, and he cannot access the number directly from the Internet.
Mysql> Grant Select,insert,update,delete on book.* to [e-mail protected] identified by ' ABC ';
If you do not want to test2 have a password, you can call another command to erase the password.
Mysql> Grant Select,insert,update,delete on book.* to [e-mail protected] identified by ';
5: Restart MySQL
[HTML]View Plaincopy
- /etc/init.d/mysql restart
[HTML]View Plaincopy
- Uninstall MySQL
- sudo apt-get autoremove–purge mysql-server-5.5//Press the TAB key specifically
- sudo apt-get remove Mysql-server
- sudo apt-get autoremove mysql-server
- sudo apt-get remove Mysql-common//This is important
Step two: Clean up residual data
1 dpkg-l |grep ^rc|awk ' {print $} ' |sudo Xargs dpkg-p
To see if the installation was successful
TCP 0 0 Localhost.localdomain:mysql *:* LISTEN-
If the server does not function correctly, you can start it by using the following command:
1 sudo/etc/init.d/mysql Restart
Fourth Step: Configure the Administrator password
Go to MySQL
1 $mysql-u root-p Administrator password
Configure the Administrator password for MySQL:
1 sudo mysqladmin-u root password newpassword
ubuntu12.04 Installing and uninstalling MySQL