Linux下安裝mysql,Linux安裝mysql

來源:互聯網
上載者:User

Linux下安裝mysql,Linux安裝mysql
一、簡易安裝
#yum install -y mysql-server mysql mysql-devel
如果報安裝包衝突:
 file /usr/share/mysql/ukrainian/errmsg.sys from install of MySQL-server-5.5.18-1.rhel5.i386 conflicts with file from package mysql-libs-5.0.46-1.rhel5.i386
把安裝包卸載就可以了
#yum -y remove mysql-libs-5.0.46-1.rhel5.i386       -y的意思就是不用詢問是否remove
卸載之後,再安裝MySQL成功

二、手動安裝
1、先上傳安裝包
/opt/MySQL-server-4.0.16-0.i386.rpm/opt/MySQL-client-4.0.16-0.i386.rpm(視情況而定,不一定要裝)
2、給檔案增加執行許可權
#cd /opt/切換到制定目錄
#chmod a+x MySQL-server-4.0.16-0.i386.rpm給檔案增加執行許可權
3、執行安裝
#rpm -ivh MySQL-server-4.0.16-0.i386.rpm
如果安裝過程報如下錯誤:file /usr/share/mysql/charsets/cp1251.xml from install of MySQL-server-5.5.24-1.el6.i686 conflicts with file from package mysql-libs-5.1.52-1.el6_0.1.i686file /usr/share/mysql/czech/errmsg.sys from install of MySQL-server-5.5.24-1.el6.i686 conflicts with file from package mysql-libs-5.1.52-1.el6_0.1.i686
原因由包衝突引起的!作業系統內建的某些包與mysql的包衝突,先移除衝突的libs包,在進行安裝
#yum -y remove mysql-libs-5.1.52*-y的意思就是不用詢問是否remove
error: Failed dependencies:        libc.so.6 is needed by MySQL-server-community-5.1.63-1.rhel4.i386        libc.so.6(GLIBC_2.0) is needed by MySQL-server-community-5.1.63-1.rhel4.i386        libc.so.6(GLIBC_2.1) is needed by MySQL-server-community-5.1.63-1.rhel4.i386
#yum install libc.so.6
卸載完成之後,再次執行安裝MySQL
#rpm -ivh MySQL-server-4.0.16-0.i386.rpm

三、設定root密碼新安裝的mysql,預設使用者root沒有密碼,需要設定密碼
#/usr/bin/mysqladmin -u root -p '123456'
如果報錯,顯示沒有許可權串連mysqladmin: connect to server at 'localhost' failederror: 'Access denied for user 'root'@'localhost' (using password: YES)'
解決方案:
先關閉資料庫#service mysqld stop
再以不檢查安全的方法啟動# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
再登入#mysql -u root mysql
再改密碼# UPDATE user SET Password=PASSWORD('newpassword') where USER='root' and host='root' or host='localhost';#FLUSH PRIVILEGES;
重啟mysql#service mysqld restart 或者#ps –aux | grep mysqld命令找出mysql的進程號然後執行kill -9 進程號殺掉mysql進程

四、授權遠端使用者登入新安裝的mysql,預設只有本機才能登入,其他電腦通過網路登入需要授權
先登陸#/usr/bin/mysql -uroot -p
再授權#grant all on *.* to root@'%' identified by '123456';#flush privileges;
好了,至此,mysql基本上可以使用了。

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.