ubuntu mysql安裝和使用者登入

來源:互聯網
上載者:User

ubuntu mysql安裝和使用者登入 安裝MySQL要安裝 MySQL,可以在終端提示符後運行下列命令: sudo apt-get install mysql-server mysql-client #中途會讓你輸入一次root使用者密碼sudo apt-get install php5-mysql  #安裝php5-mysql 是將php和mysql串連起來一旦安裝完成,MySQL 伺服器應該自動啟動。  www.2cto.com   sudo start mysql #手動的話這樣啟動sudo stop mysql #手動停止當你修改了設定檔後,你需要重啟 mysqld 才能使這些修改生效。 要想檢查 mysqld 進程是否已經開啟,可以使用下面的命令: pgrep mysqld如果進程開啟,這個命令將會返回該進程的 id。 ps -A|grep mysql 如果存在mysqld,mysqld_safe等進程的話,則會顯示出來,如:  4460 pts/0    00:00:00 mysqld_safe 4583 pts/0    00:00:01 mysqld  www.2cto.com  登入MYSQL問題: (1)mysql -u root -p  輸入密碼之後,錯誤提示如下:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES),意思是root的密碼不正確。 解決辦法如下: a.sudo mysqld_safe --user=root --skip-grant-tables --skip-networking & 輸入命令之後,提示資訊如下: [1] 5166root@jungsagacity:/home/jung# 120521 18:46:32 mysqld_safe Logging to syslog.120521 18:46:32 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql 如果提示資訊為: [2] 4928root@jungsagacity:/home/jung# 120521 18:44:40 mysqld_safe Logging to syslog.120521 18:44:40 mysqld_safe A mysqld process already exists 表示mysqld_safe進程存在,可以通過 ps -A|grep mysql 查看mysqld_safe進程ID kill -9 -xxxx            終結ID為xxxx的進程 下面繼續輸入命令: mysql -u root mysql     表示以root使用者登入到mysql資料庫當中 select * from user;        可以看到登記的使用者名稱和密碼等詳細資料。此時會看到root 對應的密碼是 123456.  www.2cto.com   實際上我們輸入 mysql -u root -p  enter password: 123456 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) 重新修改root密碼: update user set password=PASSWORD('123456') where user='root' and host='localhost'; flush privileges;      這一句話必須的輸入,否則推出mysql用戶端之後,依然登入不了。 (2)建立使用者無法登入 以root使用者身份登入到資料庫mysql之後之後,可以建立一個本地的使用者jun,推出用戶端之後,以jun進行登入,出現錯誤資訊 ERROR 1045 (28000): Access denied for user 'wujun'@'localhost' (using password: YES) 出現這個錯誤主要有以下亮點錯誤: a.建立使用者的時候,密碼以字串'xxxxxx'的形式輸入,而不是以PASSWORD('xxxxxx')形式輸入  www.2cto.com  正確的語句: mysql> insert into user(host,user,password) values('local',jun,PASSWORD('xxxxxx')); mysql> flush privileges; b.正確的輸入插入語句之後,沒有輸入 mysql> flush privileges;   作者 jungsagacity

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.