After the Mysql database is installed, you need to perform the following six subsequent operations after installing mysql on the server:
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:
The 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
The 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:
The 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:
The 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:
The 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.
The 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:
The 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:
The 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:
The 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.