mysql 安装
[root@hadoop ~]# tar -xvf mysql-5.7.26-1.el7.x86_64.rpm-bundle.tar
[root@hadoop ~]# ll
总用量 1036900
-rw-------. 1 root root 1435 1月 6 05:10 anaconda-ks.cfg
-rw-r--r--. 1 root root 530882560 5月 13 21:54 mysql-5.7.26-1.el7.x86_64.rpm-bundle.tar
-rw-r--r--. 1 7155 31415 25381952 4月 15 17:20 mysql-community-client-5.7.26-1.el7.x86_64.rpm
-rw-r--r--. 1 7155 31415 280904 4月 15 17:21 mysql-community-common-5.7.26-1.el7.x86_64.rpm
-rw-r--r--. 1 7155 31415 3838100 4月 15 17:21 mysql-community-devel-5.7.26-1.el7.x86_64.rpm
-rw-r--r--. 1 7155 31415 47076368 4月 15 17:21 mysql-community-embedded-5.7.26-1.el7.x86_64.rpm
-rw-r--r--. 1 7155 31415 24086952 4月 15 17:21 mysql-community-embedded-compat-5.7.26-1.el7.x86_64.rpm
-rw-r--r--. 1 7155 31415 130023844 4月 15 17:21 mysql-community-embedded-devel-5.7.26-1.el7.x86_64.rpm
-rw-r--r--. 1 7155 31415 2274268 4月 15 17:21 mysql-community-libs-5.7.26-1.el7.x86_64.rpm
-rw-r--r--. 1 7155 31415 2118444 4月 15 17:21 mysql-community-libs-compat-5.7.26-1.el7.x86_64.rpm
-rw-r--r--. 1 7155 31415 173541272 4月 15 17:21 mysql-community-server-5.7.26-1.el7.x86_64.rpm
-rw-r--r--. 1 7155 31415 122249684 4月 15 17:21 mysql-community-test-5.7.26-1.el7.x86_64.rpm
[root@hadoop ~]# rpm -ivh mysql-community-client-5.7.26-1.el7.x86_64.rpm
解决冲突
[root@hadoop ~]# rpm -ivh mysql-community-common-5.7.26-1.el7.x86_64.rpm
警告:mysql-community-common-5.7.26-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
准备中... ################################# [100%]
file /usr/share/mysql/czech/errmsg.sys from install of mysql-community-common-5.7.26-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.41-2.el7_0.x86_64
file /usr/share/mysql/danish/errmsg.sys from install of mysql-community-common-5.7.26-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.41-2.el7_0.x86_64
file /usr/s
[root@hadoop ~]# yum -y remove mariadb-libs-1:5.5.41-2.el7_0.x86_64
[root@hadoop ~]# rpm -ivh mysql-community-common-5.7.26-1.el7.x86_64.rpm
[root@hadoop ~]# rpm -ivh mysql-community-libs-5.7.26-1.el7.x86_64.rpm
[root@hadoop ~]# rpm -ivh mysql-community-client-5.7.26-1.el7.x86_64.rpm
[root@hadoop ~]# rpm -ivh mysql-community-server-5.7.26-1.el7.x86_64.rpm
注:ivh中, i-install
安装;v-verbose
进度条;h-hash
哈希校验
1、启动Mysql
安装完后,使用命令service mysqld start
启动MySQL服务。
[root@hadoop ~]# service mysqld start
2、修改MySql的密码
由于MySQL5.7.4之前的版本中默认是没有密码的,登录后直接回车就可以进入数据库,进而进行设置密码等操作。其后版本对密码等安全相关操作进行了一些改变,在安装过程中,会在安装日志中生成一个随机密码。
怎么找到这个随机密码呢?
使用:
[root@hadoop ~]# grep 'temporary password' /var/log/mysqld.log
2019-05-13T14:23:49.726858Z 1 [Note] A temporary password is generated for root@localhost: oyoIkilJ0q!,
[root@hadoop mysql]# mysql -uroot -p'oyoIkilJ0q!,'
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'your passwd';
Query OK, 0 rows affected (0.01 sec)
mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> select user,host from user;
+---------------+-----------+
| user | host |
+---------------+-----------+
| mysql.session | localhost |
| mysql.sys | localhost |
| root | localhost |
+---------------+-----------+
3 rows in set (0.01 sec)
mysql> update user set host='%' where user = 'root';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select user,host from user;
+---------------+-----------+
| user | host |
+---------------+-----------+
| root | % |
| mysql.session | localhost |
| mysql.sys | localhost |
+---------------+-----------+
3 rows in set (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
mysql>
2. 清理⽆⽤的库和⽤户
mysql> drop database test;
mysql> drop user 'root'@'51';
mysql> drop user 'root'@'127.0.0.1';
mysql> drop user 'root'@'::1';
mysql> drop user ''@'localhost';
mysql> drop user ''@'51';
3. 给root@localhost ⽤户设置密码
mysql> set password for 'root'@'localhost' = password(‘123456');
参考
https://www.cnblogs.com/xiaopotian/p/8196464.html