Six subsequent actions are required after the Mysql database installation is complete

  • 2020-06-19 11:50:34
  • OfStack

After installing mysql on the server, you generally need to do the following:

1. Start mysql server
2. Set up root users and add 1 more access users
3. Set user permissions
4. Configure non-local connection access
5. Backup or migrate data
6.1 Matters needing Attention (constantly updated)


1. Start mysql server
In general, the startup command we use is:

service mysqld start

A common one is the flip: Timeout error occurred to start MySQL Daemon

The solution is simple: just do it

/usr/bin/mysql_install_db  

The directory may not be the same as the default installation 1.

View the service status of mysql:


/etc/rc.d/init.d/mysqld status


2. Set up root user and add 1 more access user
By default, mysql's root account has no password. 1. Generally, a password is set for root for security:


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)

3. Set user permissions
Of course, mysql is provided for users, and one new user is needed:


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 there is a new user admin/admin, but the user has not been assigned any permissions yet.


mysql> grant ALL on *.* to admin@ " % " Identified by " admin " ;
Query OK, 0 rows affected (0.00 sec)

% on behalf of any host, of course, also can only give: select, insert, update, delete these operations permissions:


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 the local database and need to execute a command to grant access to data to any host or related host:


   mysql> update user set host = ' %' where user = ' admin';

The user admin can access the data on any host.

Or:


   mysql> GRANT ALL PRIVILEGES ON *.* TO ' root'@'%' WITH GRANT OPTION

5. Backup or migrate data
It is convenient to use mysqldump in general

6. Notes
The default mysql table name under linux is case sensitive. If you want to change the name to case insensitive, follow these steps.

1). Login with root and modify /etc/ my.cnf
2). Add a line under [mysqld] : lower_case_table_names=1
3). Restart the database


Related articles: