对于刚接触linux的同学们,安装mysql可能是一件不能顺利的事,今天就在linux上安装mysql给大家一个详细安装过程:
第一步:mysq安装
服务端:MySQL-server-community-5.1.44-1.rhel4.i386.rpm
客户端:MySQL-client-community-5.1.44-1.rhel4.i386.rpm
1、rpm -ivh MySQL-server-community-5.1.44-1.rhel4.i386.rpm
2、rpm -ivh MySQL-client-community-5.1.44-1.rhel4.i386.rpm
顺利的情况下,这种方式是可以顺利完成mysql安装的,注意安装顺序,先安装server,在安装client。
但是,如果安装出现错误,报提示缺少依赖包,就可以选择yum方式安装,方法如下:
1、yum install MySQL-server-community-5.1.44-1.rhel4.i386.rpm
2、rpm -ivh MySQL-client-community-5.1.44-1.rhel4.i386.rpm
yum方式安装,好处就是安装时会下载并且安装对应的依赖包,不需要我们在自己下载并且安装。
执行上面两种方式,mysql已经可以在linux上安装完成了。
第二步:安装后出现问题及解决方法
安装过程问题:包冲突
Transaction Check Error:
file /usr/share/mysql/charsets/README from install of MySQL-server-5.6.10-1.linux_glibc2.5.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64
file /usr/share/mysql/czech/errmsg.sys from install of MySQL-server-5.6.10-1.linux_glibc2.5.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64
file /usr/share/mysql/danish/errmsg.sys from install of MySQL-server-5.6.10-1.linux_glibc2.5.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64
file /usr/share/mysql/dutch/errmsg.sys from install of MySQL-server-5.6.10-1.linux_glibc2.5.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64
file /usr/share/mysql/english/errmsg.sys from install of MySQL-server-5.6.10-1.linux_glibc2.5.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64
解决方法:
[root@localhost ~]# yum list | grep mysqlmysql-libs.x86_64 5.1.61-1.el6_2.1 @updatesapr-util-mysql.x86_64 1.3.9-3.el6_0.1 basebacula-director-mysql.x86_64 5.0.0-9.el6 basebacula-storage-mysql.x86_64 5.0.0-9.el6 basedovecot-mysql.x86_64 1:2.0.9-2.el6_1.1 basefreeradius-mysql.x86_64 2.1.10-5.el6 baselibdbi-dbd-mysql.x86_64 0.8.3-5.1.el6 basemod_auth_mysql.x86_64 1:3.0.0-11.el6_0.1 basemysql.x86_64 5.1.61-1.el6_2.1 updatesmysql-bench.x86_64 5.1.61-1.el6_2.1 updatesmysql-connector-java.x86_64 1:5.1.12-2.el6 basemysql-connector-odbc.x86_64 5.1.5r1144-7.el6 basemysql-devel.i686 5.1.61-1.el6_2.1 updatesmysql-devel.x86_64 5.1.61-1.el6_2.1 updatesmysql-embedded.i686 5.1.61-1.el6_2.1 updatesmysql-embedded.x86_64 5.1.61-1.el6_2.1 updatesmysql-embedded-devel.i686 5.1.61-1.el6_2.1 updatesmysql-embedded-devel.x86_64 5.1.61-1.el6_2.1 updatesmysql-libs.i686 5.1.61-1.el6_2.1 updatesmysql-server.x86_64 5.1.61-1.el6_2.1 updatesmysql-test.x86_64 5.1.61-1.el6_2.1 updatesphp-mysql.x86_64 5.3.3-3.el6_2.8 updatesqt-mysql.i686 1:4.6.2-20.el6 baseqt-mysql.x86_64 1:4.6.2-20.el6 basersyslog-mysql.x86_64 4.6.2-12.el6 base
删除mysql-libs
[root@localhost ~]# yum remove mysql-libs
再次重新安装第一步方法进行安装。
安装完成后,出现问题
mysql安装完成后,service mysql start,命令启动mysql,显示启动成功。
再次,录入mysql -uroot -p,执行命令,输入用户名和密码都是提示报错:
[root@centos-server01 soft]# service mysql start;
Starting MySQL. SUCCESS!
[root@centos-server01 soft]# msyql
-bash: msyql: command not found
[root@centos-server01 soft]# mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
解决方法:
# service 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' and host='root';
mysql> FLUSH PRIVILEGES;
mysql> quit
# service mysql start
# mysql -uroot -p