数据库
首页 > 数据库> > centos 7 yum 安装 mysql glib 安装 mysql

centos 7 yum 安装 mysql glib 安装 mysql

作者:互联网

        centos 7 YUM 在线安装版

1.wget http://repo.mysql.com/mysql57-community-release-el7-10.noarch.rpm 下载

2.rpm -Uvh mysql57-community-release-el7-10.noarch.rpm 安装rpm源

3.yum install -y mysql-community-server 取决于网速

4.systemctl start mysqld.service / service mysqld start 启动mysql

5.service mysqld status 查看启动状态

6.

7.grep 'temporary password' /var/log/mysqld.log 查看mysql临时密码

8.mysql -uroot -p 登录mysql

9.ALTER USER 'root'@'localhost' IDENTIFIED BY 'root';

修改密码-> 提示: ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

10. set global validate_password_policy=0;

11. set global validate_password_length=1; 重复9步骤--->修改密码

12.GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'yourpassword' WITH GRANT OPTION; 开放远程登录

  FLUSH PRIVILEGES; 刷新配置

13.关闭防火墙

  查看防火墙 systemctl status firewalld.service / service iptables status  status/start/restart/stop --option

14.修改配置文件 

vi /etc/my.cnf 编辑my.cnf / 没有手动创建文件

 

正确配置

# For advice on how to change settings please see

# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html

 

[mysqld]

character_set_server=utf8

 

#[client]

#default-character-set=utf8

#

# Remove leading # and set to the amount of RAM for the most important data

# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.

# innodb_buffer_pool_size = 128M

#

# Remove leading # to turn on a very important data integrity option: logging

# changes to the binary log between backups.

# log_bin

#

# Remove leading # to set options mainly useful for reporting servers.

# The server defaults are faster for transactions and fast SELECTs.

# Adjust sizes as needed, experiment to find the optimal values.

# join_buffer_size = 128M

# sort_buffer_size = 2M

# read_rnd_buffer_size = 2M

datadir=/var/lib/mysql

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

 

# Disabling symbolic-links is recommended to prevent assorted security risks

symbolic-links=0

log-error=/var/log/mysqld.log

pid-file=/var/run/mysqld/mysqld.pid

 

 15.systemctl status mysqld.service 查看mysql 状态  status/start/stop/restart -- option

 

    Centos glib版安装

1.tar -zvxf mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz 解压

2.mv mysql-5.7.26-linux-glibc2.12-x86_64/* /usr/local/mysql 移动文件

3.groupadd user 添加用户

4.useradd -r -g mysql mysql 添加用户组

5.rpm -qa | grep libaio 检查libaio

6.yum -y install libaio   安装libaio

7.vi /etc/my.cnf 编辑my.cnf / 没有手动创建文件

[mysql]

# 设置mysql客户端默认字符集

default-character-set=utf8

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

[mysqld]

#skip-name-resolve

#设置3306端口

port = 3306

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

# 设置mysql的安装目录

basedir=/usr/local/mysql

# 设置mysql数据库的数据的存放目录

datadir=/usr/local/mysql/data

# 允许最大连接数

max_connections=200

# 服务端使用的字符集默认为8比特编码的latin1字符集

character-set-server=utf8

# 创建新表时将使用的默认存储引擎

#default-storage-engine=MyIsam

default-storage-engine=INNODB

#lower_case_table_name=1

max_allowed_packet=16M

8.mkdir data 创建目录

9.[root@localhost mysql]# chown -R mysql:mysql ./ 授权目录拥有者

10.[root@localhost mysql]# ./bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/ 初始化

11.成功图示

 

12.[root@localhost mysql]# cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld

13.增加 mysqld 服务控制脚本执行权限:[root@localhost mysql]# chmod +x /etc/rc.d/init.d/mysqld

14.将 mysqld 服务加入到系统服务:[root@localhost mysql]# chkconfig --add mysqld

15.检查mysqld服务是否已经生效:[root@localhost mysql]# chkconfig --list mysqld

16.[root@localhost mysql]# service mysqld start 启动mysql 提示 err目录 pid不存在

     Starting MySQL.Logging to '/usr/local/mysql/data/localhost.localdomain.err'.

     2019-07-04T02:40:27.646818Z mysqld_safe Directory '/var/lib/mysql' for UNIX socket file don't exists.

     ERROR! The server quit without updating PID file (/usr/local/mysql/data/localhost.localdomain.pid).

17.[root@localhost mysql]# mkdir /var/lib/mysql

[root@localhost mysql]# chown -R mysql /var/lib/mysql

18.再次启动

 

19.登录 提示command 

20.进行软链接

  ln -s /usr/local/mysql/bin/mysql /usr/bin

 21.

22.先进行密码设置 ,

  SET PASSWORD = PASSWORD('123456'); 设置初始密码。 不然操作不了数据库

23.提示 You must reset your password using ALTER USER statement before executing this statement.

24

25.use mysql 切到系统库

26.mysql> grant all privileges on *.* to root@"%" identified by "123456" with grant option; 授权远程登录

Query OK, 0 rows affected, 1 warning (0.00 sec)

27.mysql> flush privileges; 刷新

Query OK, 0 rows affected (0.00 sec)

28. systemctl status mysqld.service mysql 状态

29.systemctl status firewalld.service 关闭防火墙

30.

 

 完毕。整理OK。亲测可用。注意以上安装都没有配置环境变量。虚拟学习而已

标签:glib,root,mysqld,usr,mysql,var,安装,localhost
来源: https://www.cnblogs.com/1-Admin/p/11131478.html