linux安装MySql问题汇总

MySql下载地址http://mirrors.sohu.com/mysql/


1.rpm安装,安装MySQL时出现不兼容

# rpm -ivh MySQL-server-5.5.52-1.linux2.6.x86_64.rpm 


warning: MySQL-server-5.5.52-1.linux2.6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                          ################################# [100%]
        file /usr/share/mysql/charsets/README from install of MySQL-server-5.5.52-1.linux2.6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
        file /usr/share/mysql/charsets/Index.xml from install of MySQL-server-5.5.52-1.linux2.6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
        file /usr/share/mysql/charsets/armscii8.xml from install of MySQL-server-5.5.52-1.linux2.6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
        file /usr/share/mysql/charsets/ascii.xml from install of MySQL-server-5.5.52-1.linux2.6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
        file /usr/share/mysql/charsets/cp1250.xml from install of MySQL-server-5.5.52-1.linux2.6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
……


解决:yum remove mysql-libs 


2.安装过程中出现

warning: MySQL-server-5.5.52-1.linux2.6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:MySQL-server-5.5.52-1.linux2.6   ################################# [100%]
error: unpacking of archive failed on file /usr/bin/myisampack;57ea0f54: cpio: read failed - No such file or directory
error: MySQL-server-5.5.52-1.linux2.6.x86_64: install failed


解决:可能是下载过程中文件被修改或者缺失,centOS有图形界面,所以我是直接从Windows上粘贴复制过去的,后来用rz上传,就没问题了


3.如果已安装过MySql

检查一下:# rpm -qa | grep MySQL
MySQL-server-5.0.27-0.glibc23
然后,
# rpm -e --nodeps MySQL-server-5.0.27-0.glibc23
不行的话可以用#rpm -e --allmatches MySQL-server-5.0.27-0.glibc23 搞定。再
# find / -name mysql
/var/lib/mysql
/var/lib/mysql/mysql
/var/lock/subsys/mysql

mysql的相关文件应该可以手动删除了 示例 rm -rf /var/lib/mysql 


mysql启动:/etc/init.d/mysql start
mysql停止:/usr/bin/mysqladmin -u root -p shutdown


rpm命令参数: --force忽略软件包及文件的冲动
--nodeps 不检查依赖性关系
--dbpath设置RPM资料库所在的路径
--prefix 将软件包安装到由指定的目录下


4.mysql的几个重要目录

数据库目录
/var/lib/mysql/
配置文件
/usr/share/mysql(mysql.server命令及配置文件)
相关命令
/usr/bin(mysqladmin mysqldump等命令)
启动脚本
/etc/rc.d/init.d/(启动脚本文件mysql的目录)

5.修改密码
# /etc/init.d/mysql stop
# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
# mysql -u root mysql
mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root';
mysql> FLUSH PRIVILEGES;
mysql> quit
# /etc/init.d/mysql restart
# mysql -uroot -p
Enter password: <输入新设的密码newpassword>


6.获取mysql的安装路径

which mysqld

7.查看mysql的默认配置信息

通过上面的安装路径 加--verbose --help 来查看

如 /usr/local/mysql/bin/mysqld --verbose --help

8.查找mysql使用的my.cnf文件路径

/usr/local/mysql/bin/mysqld --verbose --help |grep -A 1 'Default options'

执行结果如下

Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /opt/mysql/etc/my.cnf ~/.my.cnf

系统默认是按/etc/my.cnf-----/etc/mysql/my.cnf----/usr/local/mysql/my.cnf的顺序读取配置文件的,当有多个配置文件时,mysql会以读取到的最后一个配置文件中的参数为准。


你可能感兴趣的:(MySql)