6 follow-up operations required after the MYSQL database installation is complete _mysql

Source: Internet
Author: User
Tags flush

After installing MySQL on the server, there are a few things you need to do:

1. Start MySQL server
2. Set the root user and add some access users
3. Set User permissions
4. Configure non-local connection access
5. Backing up data or migrating data
6. Some considerations (keep updating)


First, start the MySQL server
Typically, the startup commands we use are:

Copy Code code as follows:
Service mysqld Start

A common problem is to throw: Timeout error occurred trying to start MySQL Daemon

And the solution is simple: direct execution

Copy Code code as follows:
/usr/bin/mysql_install_db

The catalog may not be the same, this default installation is generally here.

To view the service status of MySQL:

Copy Code code as follows:

/ETC/RC.D/INIT.D/MYSQLD status


Two, set root user and add some access user
After the default installation, the MySQL root account does not have a password. Generally for security, you will set a password for root:

Copy Code code as follows:

mysql> Update user Set Password=password (' 123456′) where user= ' root ';
Query OK, 4 rows Affected (0.00 sec)
Rows Matched:4 Changed:4 warnings:0
mysql> FLUSH privileges;
Query OK, 0 rows Affected (0.00 sec)

Third, set user permissions
Of course, MySQL is for users to use, need to add a user for everyone to use:

Copy Code code as follows:

mysql> INSERT INTO Mysql.user (Host,user,password) VALUES (' localhost ', ' admin ', Password ("admin"));
Query OK, 1 row affected, 3 warnings (0.01 sec)
mysql> flush Privileges;
Query OK, 0 rows Affected (0.00 sec)

A new user admin/admin has been added, but the user has not assigned any permissions for the time being.

Copy Code code as follows:

Mysql> Grant all on *.* to admin@ "%" identified by "admin";
Query OK, 0 rows Affected (0.00 sec)

% represents any host, and of course it can only be given: select,insert,update,delete These operations rights:

Copy Code code as follows:

Mysql> Grant Select,insert,update,delete on *.* to admin@ "%" identified by "admin";
Query OK, 0 rows Affected (0.00 sec)
mysql> FLUSH privileges;
Query OK, 0 rows Affected (0.00 sec)

Iv. Configuring non-local connection access
By default, remote users accessing the local database are not allowed, and need to execute commands that give any host or associated host access to the data:

Copy Code code as follows:

mysql> Update user Set host = '% ' where user = ' admin ';

Access to the data is available on any host using the Admin user.

Or:

Copy Code code as follows:

Mysql> grant all privileges in *.* to ' root ' @ '% ' with GRANT OPTION

V. Backup data or migrate data
General use mysqldump more convenient

VI. Matters of note
Linux under the MySQL default table name is case-sensitive, if you need to rename the case-insensitive, you need to follow the steps below to modify.

1). Log in with root, modify/ETC/MY.CNF
2). Add a line under [mysqld]: Lower_case_table_names=1
3). Restart the database

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.