rpm -qa | grep mysql
rpm -qa | grep mariadb
存在:
[root@bigData111 module]## rpm -qa | grep mariadb
mariadb-libs-5.5.56-2.el7.x86_64
如果存在则删除:
yum -y remove mariadb-libs-5.5.56-2.el7.x86_64
mkdir /opt/software/mysql
tar -xvf mysql-5.7.19-1.el7.x86_64.rpm-bundle.tar
依次使用如下命令:
rpm -ivh --nodeps mysql-community-server-5.7.19-1.el7.x86_64.rpm
rpm -ivh --nodeps mysql-community-client-5.7.19-1.el7.x86_64.rpm
rpm -ivh mysql-community-common-5.7.19-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.19-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-compat-5.7.19-1.el7.x86_64.rpm
systemctl status mysqld
如下则为未启动状态 Active: inactive (dead)
[root@bigData111 software]## systemctl status mysqld
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: inactive (dead)
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
启动mysql服务:
systemctl start mysqld
再次检查mysql的服务是否启动
systemctl status mysqld
如下则为已启动状态:Active: active (running) since Sun 2019-09-29 15:53:20 CST; 4s ago
[root@bigData111 software]## systemctl status mysqld
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: active (running) since Sun 2019-09-29 15:53:20 CST; 4s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 1898 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
Process: 1825 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 1901 (mysqld)
CGroup: /system.slice/mysqld.service
└─1901 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid
Sep 29 15:53:13 bigData111 systemd[1]: Starting MySQL Server...
Sep 29 15:53:20 bigData111 systemd[1]: Started MySQL Server.
cat /var/log/mysqld.log | grep password
如下:
[root@bigData111 software]## cat /var/log/mysqld.log | grep password
2019-09-29T07:53:15.860473Z 1 [Note] A temporary password is generated for root@localhost: 3g:ieXDlZFjg
mysql -uroot -p然后粘贴上密码
注意:-p后面直接加密码,不要有空格
目的:更改mysql登录密码
注意事项:以下修改为临时修改,但是利用更改后规则设置的密码是永久的。
mysql> set global validate_password_policy=0;
Query OK, 0 rows affected (0.00 sec)
mysql> set global validate_password_mixed_case_count=0;
Query OK, 0 rows affected (0.00 sec)
mysql> set global validate_password_number_count=3;
Query OK, 0 rows affected (0.00 sec)
mysql> set global validate_password_special_char_count=0;
Query OK, 0 rows affected (0.00 sec)
mysql> set global validate_password_length=3;
Query OK, 0 rows affected (0.00 sec)
mysql> SHOW VARIABLES LIKE 'validate_password%';
+--------------------------------------+-------+
| Variable_name| Value |
+--------------------------------------+-------+
| validate_password_check_user_name | OFF|
| validate_password_dictionary_file | |
| validate_password_length | 3 |
| validate_password_mixed_case_count| 0 |
| validate_password_number_count | 3 |
| validate_password_policy | LOW|
| validate_password_special_char_count | 0 |
+--------------------------------------+-------+
7 rows in set (0.00 sec)
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('000000');
Query OK, 0 rows affected, 1 warning (0.00 sec)
select host,user from mysql.user;
mysql> select host,user from user;
+-----------+---------------+
| host| user |
+-----------+---------------+
| localhost | mysql.session |
| localhost | mysql.sys |
| localhost | root |
+-----------+---------------+
3 rows in set (0.00 sec)
update mysql.user set host = '%' where user = 'root';
mysql> update mysql.user set host = '%' where user = 'root';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select host,user from user;
+-----------+---------------+
| host| user |
+-----------+---------------+
| %| root |
| localhost | mysql.session |
| localhost | mysql.sys |
+-----------+---------------+
3 rows in set (0.00 sec)
flush privileges;
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
内容来源于网络,如有侵权,请联系作者删除!