mysql:
1、确认是否安装了MYSQL 旧版本或应用
# rpm -qa|grep mysql
2、卸载旧版本或应用#rpm -ev libqt4-sql-mysql-4.8.6-2.6.x86_64
3、更新Zypper 库(Adding the MySQL SLES Repository)
---
---
# rpm -Uvh mysql57-community-release-sles12-7.noarch.rpm
# zypper repos|grep mysql.*community
*本次安装mysql57-community 如果为非Yes 则需要使用以下命令
# zypper repos -E |grep mysql57-community
*使用以下命令是禁止
# sudo zypper modifyrepo -d mysql57-community
*使用以下命令是允许# sudo zypper modifyrepo -e mysql57-community
# sudo zypper refresh
4、安装MySQL 5.7 Server (Installing MySQL with Zypper)
# sudo zypper install mysql-community-server
5、初始化配置MySQL 5.7 (Starting the MySQL Server)
# sudo service mysql stop
# sudo service mysql start
-----
报错:
# vim /var/log/mysql/mysqld.log
2016-10-08T02:48:46.797210Z 0 [ERROR] Could not open unix socket lock file /var/lib/mysql/mysql.sock.lock.
2016-10-08T02:48:46.797227Z 0 [ERROR] Unable to setup unix socket lock file.
2016-10-08T02:48:46.797243Z 0 [ERROR] Aborting
解决:
rm /var/lib/mysql/mysql.sock rm /var/lib/mysql/mysql.sock.lock
可以这样修改密码---跳过授权
修改my.cnf配置文件
# sudo vi /etc/my.cnf 在[mysqld]的段中加上一句:skip-grant-tables,如下: [mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock skip-grant-tables 重启服务 # sudo systemctl restart mysqld 登陆并修改密码 # mysql -uroot
mysql> use mysql
MySQL 5.7.6 以及最新版本:
mysql> update user set authentication_string=PASSWORD('rzrk123456') where User='root';
MySQL 5.7.5 或更早之前的版本:
# mysql> update user set password=PASSWORD('newpass') where User='root';
登陆测试
将my.cnf的设置修改回来,重启MySQL服务,并登陆测试:
-----
*查询安装系统时所生成的随机密码
# grep "password" /var/log/mysql/mysqld.log
2016-09-27T07:45:58.815397Z 1 [Note] A temporary password is generated for root@localhost: zrp=hfIo&3VF
# mysql -uroot -p --密码为所查询到的随机密码
mysql> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement. ---报错
*初始化密码,密码复杂性报错
mysql> set password=PASSWORD('rzrk123');
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
*修改密码复杂性值:0orLOW
mysql> set global validate_password_policy=0;
Query OK, 0 rows affected (0.00 sec)
*修改初始密码;
mysql> SET PASSWORD = PASSWORD('rzrk123456'); ---红色为密码
成功!!更改数据库存储路径:
1.检查mysql数据库存放目录
# mysql -uroot -przrk123456
mysql> show variables like '%dir%';
+-----------------------------------------+-------------------------------+
| Variable_name | Value |
+-----------------------------------------+-------------------------------+
| basedir | /usr/ |
| binlog_direct_non_transactional_updates | OFF |
| character_sets_dir | /usr/share/mysql/charsets/ |
| datadir | /home/rzrk/server/data/mysql/ |
| ignore_db_dirs | |
| innodb_data_home_dir | |
| innodb_log_group_home_dir | ./ |
| innodb_max_dirty_pages_pct | 75.000000 |
| innodb_max_dirty_pages_pct_lwm | 0.000000 |
| innodb_tmpdir | |
| innodb_undo_directory | ./ |
| lc_messages_dir | /usr/share/mysql/ |
| plugin_dir | /usr/lib64/mysql/plugin/ |
| slave_load_tmpdir | /tmp |
| tmpdir | /tmp |
+-----------------------------------------+-------------------------------+
2.停止mysql服务
3.创建新的数据库存放目录
4.移动之前的目录文件到新的目录文件
cp -R /var/lib/mysql/* /home/rzrk/server/data/mysql
chown mysql:mysql /home/rzrk/server/data/mysql -R
vim /etc/my.cnf
datadir=/home/rzrk/server/data/mysql
重启mysql服务