mysql基礎操作

來源:互聯網
上載者:User

標籤:mysql

啟動  關閉

/etc/init.d/mysqld  start

netstat -lntup | grep 3306

 ps -ef | grep mysql | grep -v grep

root       1946      1  0 01:51 pts/1    00:00:00 /bin/sh /application/mysql/bin/mysqld_safe --datadir=/application/mysql/data --pid-file=/application/mysql/data/lnmp.com.pid

mysql      2187   1946  0 01:51 pts/1    00:00:00 /application/mysql/bin/mysqld --basedir=/application/mysql --datadir=/application/mysql/data --plugin-dir=/application/mysql/lib/plugin --user=mysql --log-error=/application/mysql/data/lnmp.com.err --pid-file=/application/mysql/data/lnmp.com.pid --socket=/tmp/mysql.sock --port=3306

 vim /etc/init.d/mysqld            //啟動過程

$bindir/mysqld_safe --datadir="$datadir" --pid-file="$mysqld_pid_file_path" $other_args >/d ev/null 2>&1 &

mysqld_safe  --user=mysql  &         //初始化時給出的啟動方法

/etc/init.d/mysqld  stop

ss -lnt | grep 3306

LISTEN     0      50                        *:3306

killall   mysqld     pkill  mysqld     killall -9  mysqld   //盡量不要粗魯的關閉資料庫


mysqladmin -uroot -p123456  shutdown

登陸

ifconfig   //看是否是測試還是正式環境,,,備份資料庫

mysql                         

mysql -uroot  -p


mysql> prompt \[email protected]  \r:\m:\s->                     //修改提示符

[email protected]  02:13:09->


[mysql]

prompt \[email protected]  \r:\m:\s->                        //    /etc/my.cnf

協助

mysql> help

exit

密碼


mysqladmin -u root password‘123456‘         //最常用  簡單  實用

mysqladmin -u root -p‘123456‘ password ‘123123‘


select  user,host,password  from mysql.user;

mysql> update  mysql.user  set   password=password(456)  where user=‘root‘  and host=‘localhost‘;              //要指定條件

mysql> set password=password(‘123123‘);

mysql> flush  privileges;

找回mysql root使用者密碼


/etc/init.d/mysqld stop

mysqld_safe  --skip-grant-tables  --user=mysql &    //忽略授權表如果是編譯的,預設是/usr/local/mysql              會有報錯。

sed -i  ‘s#/usr/local/mysql#/application/mysql#g‘   /application/mysql/bin/mysqld_safe


update user set password=password(新密碼) where user=‘root‘ and    host=‘localhost‘;==>設定新密碼

flush privileges;==>重新整理

新開視窗 mysqladmin -uroot -p shutdown ==>新密碼測試關掉資料庫,成功關閉就證明修改成功


//多執行個體要指定  mysqld_safe   --defaults-file=/data/3306/my.cnf  --skip-grant-tables 


mysqld_safe --skip-grant-tables --skip-networking  &

// skip-networking         

開啟該選項後就不能遠端存取MySQL

為安全考慮希望指定的IP訪問MySQL,可以在設定檔中增加bind-address=IP,前提是關閉skip-networking


本文出自 “何全” 部落格,請務必保留此出處http://hequan.blog.51cto.com/5701886/1771935

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.