sudo apt-get install mysql-server mysql-clientjava
sudo netstat -tap | grep mysqlmysql
sudo vim /etc/mysql/my.cnf
web
/etc/init.d/mysql start/stop
sql
sudo apt-get autoremove --purge mysql-server-5.5.43 sudo apt-get remove mysql-server sudo apt-get autoremovemysql-server sudo apt-get remove mysql-common dpkg -l | grep ^rc| awk '{print $2}' | sudoxargsdpkg -P
[plain] view plaincopy/usr/bin 客戶端程序和腳本 /usr/sbin mysqld 服務器 /var/lib/mysql 日誌文件,數據庫 [重點要知道這個] /usr/share/doc/packages 文檔 /usr/include/mysql 包含( 頭) 文件 /usr/lib/mysql 庫 /usr/share/mysql 錯誤消息和字符集文件 /usr/share/sql-bench 基準程序
在ubuntu下安裝了mysql 5 server,結果不知道什麼緣由,安裝時輸入的root賬號密碼在使用時不管如何都不能經過數據庫服務器的驗證。無奈只有重置mysql的root賬號密碼。查了一下,用瞭如下方法成功的重置了root賬號密碼首先中止mysql服務: 數據庫
複製代碼代碼以下:ubuntu
root@webserver :/home/webmaster# service mysql stop vim
接着採用忽略密碼認證模式從新建立一個mysql服務:
windows
複製代碼代碼以下:服務器
root@webserver :/home/webmaster# mysqld --user=mysql --skip-grant-tables --skip-networking & socket
成功啓動後返回PID及其它啓動信息
複製代碼代碼以下:
[1] 3591
root@webserver :/home/webmaster# 121005 2:59:27 [Note] Plugin 'FEDERATED' is disabled.
121005 2:59:27 InnoDB: The InnoDB memory heap is disabled
121005 2:59:27 InnoDB: Mutexes and rw_locks use GCC atomic builtins
121005 2:59:27 InnoDB: Compressed tables use zlib 1.2.3.4
121005 2:59:27 InnoDB: Initializing buffer pool, size = 128.0M
121005 2:59:27 InnoDB: Completed initialization of buffer pool
121005 2:59:27 InnoDB: highest supported file format is Barracuda.
121005 2:59:27 InnoDB: Waiting for the background threads to start
121005 2:59:28 InnoDB: 1.1.8 started; log sequence number 1595685
121005 2:59:28 [Note] mysqld: ready for connections.
Version: '5.5.24-0ubuntu0.12.04.1' socket: '/var/run/mysqld/mysqld.sock' port: 0 (Ubuntu)
鏈接到mysql系統庫:
複製代碼代碼以下:
root@webserver :/home/webmaster# mysql -u root mysql
鏈接到mysql庫後直接修改root賬號的密碼爲新的密碼'mynewpasswd':
複製代碼代碼以下:
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> update user set Password=PASSWORD('mynewpasswd') where user='root';
Query OK, 3 rows affected (0.00 sec)
Rows matched: 3 Changed: 3 Warnings: 0
mysql> FLUSH PRIVILEGES;
mysql> quit;
Bye
停止mysql服務進程(PID 3591見前面啓動服務時的屏幕信息):
複製代碼代碼以下:
root@webserver :/home/webmaster# kill 3591
正常啓動 mysql服務,並用新密碼登陸mysql服務器成功:
複製代碼代碼以下:
root@webserver:/home/webmaster#service mysql start
root@webserver:/home/webmaster#mysql -u root -pmynewpasswd
Linux(Ubuntu) 安裝mysql,windows使用Navicat 鏈接
第四步 配置my.cnf:
使用 sudo netstat -lntp 命令看看
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN
若是上面0 0.0.0.0後面不是3306的話就打開/etc/mysql/my.cnf 吧下面這一行給註釋掉
bind-address = 127.0.0.1
修改配置之後記得要重啓mysql
第五步 分配權限:
本機登錄mysql:mysql -u root -p (-p必定要有);改變數據庫:use mysql;
從全部主機:grant all privileges on *.* to root@"%" identified by "password" with grant option;
從指定主機:grant all privileges on *.* to root@"192.168.11.205" identified by "password" with grant option;
例如:
grant all privileges on *.* to test@'192.168.113.124' identified by '123456'
而後執行
flush privileges;
查看一下user:
select host,user,password from user;
看看剛剛添加的用戶是否存在
第六步 使用Navicat 鏈接:
填好服務器IP,剛剛添加的用戶名跟密碼,鏈接吧。有時候可能因爲防火牆的緣由沒法鏈接,把防火牆給關閉試試。
查看防火牆狀態:sudo ufw status
關閉防火牆:sudo ufw disable
開啓防火牆:sudo ufw enable
開放端口:sudo ufw allow 3306 (能夠只開3306端口,mysql默認使用的3306端口)
關閉端口:sudo ufw delete allow 3306
容許特定IP:sudo ufw allow from 192.168.113.254
刪除特定IP:sudo ufw delete allow from 192.168.113.254