ubuntu12.04 Installing and uninstalling MySQL

Source: Internet
Author: User
Tags administrator password

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
    1. Apt-get Update

Otherwise, you may not find the installation file error prompt

2: Install MySQL server and client

[HTML]View Plaincopy
    1. 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
    1. Vi/etc/mysql/my.cnf
[HTML]View Plaincopy
    1. 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
    1. 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
    1. /etc/init.d/mysql restart

[HTML]View Plaincopy
    1. Uninstall MySQL
    2. sudo apt-get autoremove–purge mysql-server-5.5//Press the TAB key specifically
    3. sudo apt-get remove Mysql-server
    4. sudo apt-get autoremove mysql-server
    5. 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.