mysql 二进包在linux下安装过程
cp mysql-5.6.17-linux-glibc2.5-i686 /usr/local/mysql -r
groupadd mysql和useradd -r -g mysql mysql
进入安装mysql软件目录:执行命令 cd /usr/local/mysql
修改当前目录拥有者为mysql用户:执行命令 chown -R mysql:mysql ./
./scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql
修改当前目录拥有者为root用户:执行命令 chown -R root:root ./
修改当前data目录拥有者为mysql用户:执行命令 chmod -R 755 /usr/local/mysql/data chmod -R 755 /usr/local/mysql/data/mysql
cp support-files/mysql.server /etc/init.d/mysql
service mysql start
mysqladmin -u root password '密码'
--连接myql后在mysql提示符下执行以下语句
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;
flush privileges;
rpm包的安装过程如下:
第一步:官网上下载安装包mysql-5.7.28-1.el7.x86_64.rpm-bundle.tar ,下载地址 https://downloads.mysql.com/archives/community/
第二步:解压 tar -xvf mysql-5.7.28-1.el7.x86_64.rpm-bundle.tar ,得到如下文件:
mysql-community-embedded-compat-5.7.28-1.el7.x86_64.rpm
mysql-community-embedded-devel-5.7.28-1.el7.x86_64.rpm
mysql-community-client-5.7.28-1.el7.x86_64.rpm
mysql-community-libs-5.7.28-1.el7.x86_64.rpm
mysql-community-common-5.7.28-1.el7.x86_64.rpm
mysql-community-libs-compat-5.7.28-1.el7.x86_64.rpm
mysql-community-devel-5.7.28-1.el7.x86_64.rpm
mysql-community-server-5.7.28-1.el7.x86_64.rpm
mysql-community-embedded-5.7.28-1.el7.x86_64.rpm
mysql-community-test-5.7.28-1.el7.x86_64.rpm
第三步:执行rpm -ivh mysql-community-common-5.7.28-1.el7.x86_64.rpm 安装,如果出现以下错误,
则说明当前 linux系统上有默认安装,需要先卸载 , 先执行 rpm -qa | grep mariadb 查询出要卸载的包,
rpm -e mariadb-libs-5.5.41-2.el7_0.x86_64 删除,会报如下错:
error: Failed dependencies:
libmysqlclient.so.18()(64bit) is needed by (installed) postfix-2:2.10.1-6.el7.x86_64
libmysqlclient.so.18(libmysqlclient_18)(64bit) is needed by (installed) postfix-2:2.10.1-6.el7.x86_64
说明存在依赖关系,强制卸载
rpm -e --nodeps mariadb-libs-5.5.41-2.el7_0.x86_64
第四步:安装mysql-community-client包,rpm -ivh mysql-community-client-5.7.21-1.el7.x86_64.rpm,出现以下错误:
warning: mysql-community-client-5.7.21-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
mysql-community-libs(x86-64) >= 5.7.9 is needed by mysql-community-client-5.7.21-1.el7.x86_64
根据提示先安装 mysql-community-libs包 rpm -ivh mysql-community-libs-5.7.21-1.el7.x86_64.rpm,然后再尝试尝试安装mysql-client
第五步:安装mysql-server
rpm -ivh mysql-community-server-5.7.21-1.el7.x86_64.rpm
第六步:查看mysql的服务 systemctl status mysqld.service
mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled)
Active: inactive (dead)
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
第七步:启动mysql服务 systemctl start mysqld.service
第八步:查看临时密码 grep "password" /var/log/mysqld.log
[root@hadoop software]# grep "password" /var/log/mysqld.log 2020-02-14T11:26:05.038127Z 1 [Note] A temporary password is generated for root@localhost: !<kiTH=DZ53o
第九步:使用临时密码登录,然后修改root的密码
mysql -uroot -p
第十步:修改root密码:
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'hangzhou123';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
报错的原因:其实与validate_password_policy的值有关。默认是1,即MEDIUM,所以刚开始设置的密码必须符合长度,且必须含有数字,小写或大写字母,特殊字符。
解决方法:
修改validate_password_policy参数的值
mysql> set global validate_password_policy=0;
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'hangzhou';
mysql> select @@validate_password_length;
+----------------------------+
| @@validate_password_length |
+----------------------------+
| 8 |
+----------------------------+
1 row in set (0.05 sec)
第十一步:使用新密码再次登录,登录成功
mysql -uroot -phangzhou
以上安装没想到如此麻烦,还好网上找到一篇文章,以上基本参考此文完成:http://blog.itpub.net/31015730/viewspace-2152272/