MySQL安裝配置

來源:互聯網
上載者:User

標籤:

目錄:

1.下載

2.Windows部署

3.CentOS部署

4.設定

5.參考資料

1.下載

  :http://dev.mysql.com/downloads/mysql/

2.Windows部署

  2.1.下載並解壓mysql-5.7.10-winx64.zip

  2.2.複製my-default.ini,並重新命名為my.ini

basedir = E:\\mysql-5.7.10-winx64             --檔案目錄datadir = E:\\mysql-5.7.10-winx64\\data     --資料庫資料目錄port = 3306

  2.3.系統內容變數PATH追加[basedir]\bin (例如E:\mysql-5.7.10-winx64\bin),以";"隔開。

  2.4.在命令列視窗(CMD)下輸入:

#MySQL 5.7.7以上,zip內不包含data目錄需首先輸入$ mysqld --initialize  或者mysqld --initialize-insecure$ mysqld -install 安裝mysql服務$ net start mysql                --啟動服務
$ net stop mysql --停止服務
3.CentOS部署

  使用rpm包安裝

  2.1.下載對應系統版本的mysql-community-server,mysql-community-client,mysql-community-common,mysql-community-devel,mysql-community-libs或者下載mysql-[版本號碼].rpm-bundle.tar。

$ rpm -ivh [包名]

$ service mysqld start --啟動服務
$ chkconfig mysqld on --開機啟動
4.設定

  windows下設定檔為my.ini,CentOS下設定檔為/etc/my.cnf

  4.1修改root初始密碼

    windows:

#如果使用mysqld --initialize 使用$ mysql -u root -pEnter password: (enter the random root password here)#如果使用mysqld --initialize-insecure 使用$ mysql -u root --skip-passwordmysql> use mysqlmysql> ALTER USER ‘root‘@‘localhost‘ IDENTIFIED BY ‘new_password‘;mysql> flush privileges;或者mysql> UPDATE user SET authentication_string= password (‘new_password‘) WHERE User=‘root‘;mysql> flush privileges;

或者
mysql> set password for ‘root‘@‘localhost‘ = password(‘new_password‘);

或者
$ mysqladmin -u root -h localhost -p password ‘new_password‘

PS:特別提醒注意的一點是,新版的mysql資料庫下的user表中已經沒有Password欄位了,取而代之的是authentication_string

    CentOS:

    舊版本的mysql的root初始隨機密碼在.mysql_secret檔案中,新版本的在記錄檔中。

    密碼修改如windows部分。

  4.2.密碼不到期配置:在設定檔中加入:default_password_lifetime=0,設定為:0表示密碼永不到期

  4.3.遠端存取:

$ mysql> grant all privileges on *.* to ‘root‘@‘%‘ identified by ‘new_password‘ with grant option;
5.參考資料

  http://www.mysql.com/

  http://dev.mysql.com/doc/

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.