linux系统下安装mysql rpm 包 (32位)
这里写自定义目录标题
- 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
- Disabling symbolic-links is recommended to prevent assorted security risks
由于电脑是32位系统的centos6.5,搜罗了网上一圈都没有很好的解决详细的流程,所以这里给罗列一下:
首先要到官网下载好四个rpm包,如下:
①下载linux版本的mysql
mysql下载官网:https://dev.mysql.com/downloads/
点 MySQL Community Server==》再点击选32位的
点击右上角Looking for the latest GA version?选版本,我的是5.7.30
安装之前要先卸载原来的mysql:
1.查看是否安装Mysql
[[email protected] module]$ rpm -qa | grep -i mysql
MySQL-client-5.6.24-1.el6.x86_64
MySQL-server-5.6.24-1.el6.x86_64
2.查看MySQL服务是否启动,关闭
[[email protected] module]$ sudo service mysql status
[sudo] password for atguigu:
MySQL running (2681) [确定]
[[email protected] module]$ sudo service mysql stop
Shutting down MySQL… [确定]
3.卸载MySQL安装的组件
[[email protected] module]$ sudo rpm -e MySQL-server-5.6.24-1.el6.x86_64
[sudo] password for atguigu:
[[email protected] module]$ sudo rpm -e MySQL-client-5.6.24-1.el6.x86_64
4.查找并删除MySQL相关的文件
[[email protected] module]$ whereis mysql
mysql: /usr/lib64/mysql
[[email protected] module]$ sudo find / -name mysql
/var/lib/mysql
/var/lib/mysql/mysql
/usr/lib64/mysql
[[email protected] module]$ sudo rm -rf /var/lib/mysql
[[email protected] module]$ sudo rm -rf /usr/lib64/mysql
把它复制到linux下,无需解压,直接安装:
[[email protected] mysql-libs]# rpm -ivh mysql-community-common-5.7.30-1.el6.i686.rpm
[[email protected] mysql-libs]# rpm -ivh mysql-community-libs-5.7.30-1.el6.i686.rpm
[[email protected] mysql-libs]# rpm -ivh mysql-community-client-5.7.30-1.el6.i686.rpm
[[email protected] mysql-libs]#rpm -ivh mysql-community-server-5.7.30-1.el6.i686.rpm
这里注意先要安装common 和lib 再安装client和server,他们是会相互依赖的
安装好后先查看 service mysql status,然后居然报:
mysqld:未被识别的服务
所以我换一种方式启动
先修改 vim etc/my.conf 文件把 basedir=/xxx/xxx注释掉
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
#basedir=/usr/share/mysql
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
然后把datadir下路径下数据干掉:[[email protected]]rm -rf /var/lib/mysql/*
再进行初始化:[[email protected]] mysqld --initialize 直接回车,执行初始化…稍等一会就OK了
再启动:service mysqld start
查看状态:service mysqld status
安装好后由于5.6以后是无法通过cat /root/.mysql_secret命令查看到密码的所以要到 log-error指定的路径 cat /var/log/mysqld.log 文件里找到如下一行里:2020-05-13T05:58:45.920596Z 1 [Note] A temporary password is generated for [email protected]: gwsxk?sD?9zZ
其中: gwsxk?sD?9zZ 就是mysql自动生成的密码
最后登录mysql:[[email protected]] mysql -uroot -pgwsxk?sD?9zZ
最后再更改密码就可以了
3.修改密码
mysql>SET PASSWORD=PASSWORD(‘000000’);