After installing mysql on the server, you generally need to do the following:
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. Back up or migrate data
6. Some precautions (Continuous updates)
1. Start mysql server
Generally, the following startup commands are used:
Copy codeThe Code is as follows: service mysqld start
A common problem is: Timeout error occurred trying to start MySQL Daemon.
The solution is also simple: simply execute
Copy codeThe Code is as follows:/usr/bin/mysql_install_db
The directory may be different. The default installation is usually here.
View the service status of mysql:
Copy codeThe Code is as follows:
/Etc/rc. d/init. d/mysqld status
2. Set the root user and add some Access Users
By default, the root account of mysql does not have a password after installation. Generally, a password is set for root to ensure security:
Copy codeThe Code is as follows:
Mysql> update user set password = PASSWORD ('000000') 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)
3. Set User Permissions
Of course, mysql is provided to users and needs to be added to users:
Copy codeThe Code is 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)
Now a new user admin/admin is added, but the user has not been assigned any permissions yet.
Copy codeThe Code is as follows:
Mysql> grant ALL on *. * to admin @ "%" Identified by "admin ";
Query OK, 0 rows affected (0.00 sec)
% Represents any host. Of course, only select, insert, update, and delete operations can be granted:
Copy codeThe Code is 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)
4. Configure non-local connection access
By default, remote users are not allowed to access local databases. You need to execute commands to grant data access permissions to any host or related host:
Copy codeThe Code is as follows:
Mysql> update user set host = '%' where user = 'admin ';
You can use the admin user to access data on any host.
Or:
Copy codeThe Code is as follows:
Mysql> grant all privileges on *. * TO 'root' @ '%' WITH GRANT OPTION
V. Back up or migrate data
It is easier to use mysqldump
Vi. Precautions
In linux, the default mysql table name is case-sensitive. to rename a table that is case-insensitive, follow these steps.
1) log on with root and modify/etc/my. cnf
2) Add a row under [mysqld]: lower_case_table_names = 1
3). Restart the database.