Use the yum command to install MySQL under Linux

Use yum to install MySQL under Linux, and start, log in, and remotely access the MySQL database.

1. Installation

Check if it is installed:

yum list installed mysql*

rpm -qa | grep mysql*

Check if the package is installed:

yum list mysql*

Install the mysql client:

yum install mysql

Install mysql server side:

yum install mysql-server

yum install mysql-devel

2. Start && Stop

Database character set settings

Add default-character-set=utf8 to the mysql configuration file /etc/my.cnf

Start the mysql service:

service mysqld start or /etc/init.d/mysqld start

boot:

chkconfig -add mysqld, check whether the startup settings are successful chkconfig --list | grep mysql*

mysqld 0: off 1: off 2: on 3: on 4: on 5: on 6: off

stop:

service mysqld stop

3. Login

Create root administrator: mysqladmin -u root password 123456

Login: mysql -u root -p Enter the password.

Forgot password: service mysqld stop

mysqld_safe --user=root --skip-grant-tables

mysql -u root

use mysql

update user set password=password("new_pass") where user="root";

flush privileges;

4. Remote access

Open firewall port number

Adding permissions to mysql: A new record is added to the user table in the mysql library. The host is "%" and the user is "root".

 

mysql>mysql -u root -p;

mysql>use mysql;

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

mysql>select host, user from user;

mysql>flush privileges;

 

 

5. Several important directories of Linux MySQL

Database directory: /var/lib/mysql/

Configuration file: /usr/share /mysql (mysql.server command and configuration file)

Related commands: /usr/bin (commands such as mysqladmin mysqldump)

Startup script: /etc/rc.d/init.d/ (directory of startup script file mysql)

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326018079&siteId=291194637