linux下安裝mysql

來源:互聯網
上載者:User

標籤:

a、從mysql官網下載linux對應的三個檔案

MySQL-server-5.6.30-1.el6.x86_64.rpmMySQL-devel-5.6.30-1.el6.x86_64.rpmMySQL-client-5.6.30-1.el6.x86_64.rpm

b、檢查mysql是否已經安裝,如果有安裝則刪除

[[email protected] ~]# rpm -qa | grep -i mysql[[email protected] ~]# yum -y remove mysql-libs*

c、安裝mysql

[[email protected] rpm]# rpm -ivh MySQL-server-5.6.30-1.el6.x86_64.rpm[[email protected] rpm]# rpm -ivh MySQL-devel-5.6.30-1.el6.x86_64.rpm[[email protected] rpm]# rpm -ivh MySQL-client-5.6.30-1.el6.x86_64.rpm

d、修改mysql設定檔的位置

[[email protected] rpm]# cp /usr/share/mysql/my-default.cnf /etc/my.cnf

e、初始化mysql和設定密碼

[[email protected] rpm]# /usr/bin/mysql_install_db[[email protected] rpm]# service mysql start#查看root帳號密碼[[email protected] rpm]# cat /root/.mysql_secret  # The random password set for the root user at Wed Dec 11 23:32:50 2013 (local time): YsFtYd[[email protected] ~]# mysql -uroot –YsFtYd
#設定密碼為root mysql> SET PASSWORD = PASSWORD(‘root); mysql> exit [[email protected] ~]# mysql -uroot -proot

f、遠程登入使用者佈建

mysql> select host,user,password from user;+-----------------------+------+-------------------------------------------+| host                  | user | password                                  |+-----------------------+------+-------------------------------------------+| localhost             | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B || localhost.localdomain | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B || 127.0.0.1             | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B || ::1                   | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |+-----------------------+------+-------------------------------------------+mysql> update user set password=password(‘123456‘) where user=‘root‘;mysql> update user set host=‘%‘ where user=‘root‘ and host=‘localhost‘;mysql> flush privileges;mysql> exit

g、設定開機啟動

[[email protected] ~]# chkconfig mysql on[[email protected] ~]# chkconfig --list | grep mysqlmysql    0:off   1:off   2:on    3:on    4:on    5:on    6:off

h、mysql的預設安裝位置

#資料庫目錄/var/lib/mysql/#設定檔目錄/usr/share/mysql#相關命令目錄/usr/bin#啟動指令碼/etc/init.d/mysql

i、修改字元集

[[email protected] /]# vi /etc/my.cnf[client]password=rootport=3306default-character-set=utf8[mysqld]port=3306character_set_server=utf8character_set_client=utf8collation-server=utf8_general_ci#(注意linux下mysql安裝完後是預設:表名區分大小寫,列名不區分大小寫; 0:區分大小寫,1:不區分大小寫)lower_case_table_names=1#(設定最大串連數,預設為 151,MySQL伺服器允許的最大串連數16384; )max_connections=151[mysql]default-character-set = utf8

j、遠端連線mysql設定

①授權[[email protected] /]# mysql -uroot -prootmysql> use mysql;mysql>GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘%‘ IDENTIFIED BY ‘這裡是你的密碼‘ WITH GRANT OPTION;②關閉防火牆#關閉命令[[email protected] /] service iptables stop #永久關閉防火牆[[email protected] /] chkconfig iptables off 

至此mysql就安裝完成並配置完成

  

 

linux下安裝mysql

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.