Home > Database > Mysql Tutorial > How to use yum to install mysql under Linux

How to use yum to install mysql under Linux

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2023-06-01 21:07:04
forward
1070 people have browsed it

\1. First check whether the system is equipped with mysql

[root@localhost ~]#yum list installed mysql*[root@localhost ~]#rpm –qa|grep mysql*
Copy after login

\2. Check whether there is an installation package

[root@localhost ~]#yum list mysql*
Copy after login

\3. Install the mysql client

[root@localhost ~]yum install mysql
Copy after login

\4. Install the mysql server

[root@localhost ~]#yum install mysql-server[root@localhost ~]#yum install mysql-devel
Copy after login

\5. Add the default character set to the /etc/my.cnf file

[root@localhost ~]#vim /etc/my.cnf
Copy after login
How to use yum to install mysql under Linux

\6. Start or shut down the mysql service

[root@localhost ~]#service mysqld start --启动mysql 或者 /etc/init.d/mysqld start (关闭mysql #service mysql stop)
Copy after login

\7. Set up the mysql service at boot

[root@localhost ~]# chkconfig --add mysqld
Copy after login
How to use yum to install mysql under Linux

\ 8. Create root user with password 123456

mysqladmin –u root password 123456

[root@localhost ~]# mysqladmin -u root password 123456
Copy after login

\9. Connect to mysql

[root@localhost ~]# mysql -u root -p   --输入密码123456
Copy after login
How to use yum to install mysql under Linux

\10. Set remote access permissions

mysql> use mysql
mysql> GRANT ALL PRIVILEGES ON *.* TO ‘admin’@’%’IDENTIFIED BY ‘admin’ WITH GRANT OPTION;

--第一个admin为用户名,第二个admin为密码,%表示所有的电脑都可以链接

mysql> flush privileges; --设置立即生效
Copy after login
How to use yum to install mysql under Linux
mysql> SELECT DISTINCT CONCAT('User:''',user,'''@''',host,''';') AS query FROM mysql.user;
mysql> exit; --退出mysql服务
[root@localhost ~]# vi /etc/my.cnf[mysqld]

datadir=/var/lib/mysql

socket=/var/lib/mysql/mysql.sock

user=mysql

default-character-set=utf8# Disabling symbolic-links is recommended to prevent assorted security riskssymbolic-links=0#设备地址bind-address=0.0.0.0 #设置设备地址[mysqld_safe]log-error=/var/log/mysqld.log

pid-file=/var/run/mysqld/mysqld.pid
Copy after login
[root@localhost ~]# service mysqld start --重启mysql服务[root@localhost ~]# mysql -u root -p --连接mysql输入密码mysql> show global variables like 'port'; --查看端口号

+---------------+-------+

| Variable_name | Value |

+---------------+-------+

| port          | 3306  |

+---------------+-------+

1 row in set (0.00 sec)
Copy after login

11. Use navcat to connect to mysql

How to use yum to install mysql under Linux

Done. . .

The above is the detailed content of How to use yum to install mysql under Linux. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template