ubuntu環境中mysql的安裝與解除安裝

2021-10-09 04:45:43 字數 2643 閱讀 3020

sudo apt-get install mysql-server          //服務端

sudo apt-get install mysql-client //客戶端

sudo apt-get install libmysqlclient-dev //程式編譯時鏈結的庫

service mysql start 			//啟動mysql服務

service mysql stop //關閉mysql服務

sudo netstat -tap | grep mysql //檢視mysql節點listen狀態

mysql -u root -p //進入mysql shell介面

xt@xt-virtual-machine:~$ sudo cat /etc/mysql/debian.cnf

# automatically generated for debian scripts. do not touch!

[client]

host = localhost

user = debian-sys-maint

password = vtuhxfg5tyjolr2l

socket = /var/run/mysqld/mysqld.sock

[mysql_upgrade]

host = localhost

user = debian-sys-maint

password = vtuhxfg5tyjolr2l

socket = /var/run/mysqld/mysqld.sock

xt@xt-virtual-machine:~$ mysql -u debian-sys-maint -p

enter password:

welcome to the mysql monitor. commands end with ; or \g.

your mysql connection id is 4

server version: 5.7.31-0ubuntu0.18.04.1 (ubuntu)

oracle is a registered trademark of oracle corporation and/or its

affiliates. other names may be trademarks of their respective

owners.

type 'help;' or '\h' for help. type '\c' to clear the current input statement.

mysql> use mysql; #連線到mysql資料庫

mysql> update mysql.user set authentication_string=password('123456') where user='root' and host ='localhost'; #修改密碼123456是密碼

mysql> update user set plugin="mysql_native_password";

mysql> flush privileges;

mysql> quit;

service mysql restart

sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf

skip-grant-tables

service mysql restart

show databases					//檢視所有資料庫,mysql資料庫用來新增使用者修改密碼

use mysql //開啟相關庫

show tables //檢視該庫中的所有表

describe //檢視表結構

sudo rm /var/lib/mysql/ -r 		//刪除mysql的資料檔案

sudo rm /etc/mysql/ -r //刪除mysql的配置檔案

sudo apt-get autoremove mysql* --purge //自動解除安裝mysql(包括server和client)

dpkg --list|grep mysql //檢視mysql的依賴項

sudo apt-get remove dbconfig-mysql

sudo apt-get remove mysql-client

sudo apt-get remove mysql-client-5.7

sudo apt-get remove mysql-client-core-5.7

sudo apt-get autoremove mysql* --purge

dpkg --list|grep mysql

sudo apt-get remove php7.0-mysql

dpkg -l|grep ^rc|awk ''|sudo xargs dpkg -p //清除殘留資料

dpkg --list|grep mysql //再次檢視mysql的剩餘依賴項

Ubuntu環境下配置mysql

安裝mysql 用apt get直接安裝,可以省去配置環境的煩惱 sudo apt get install mysql server mysql client libmysqlclient dev安裝完成後會自動啟動mysql,也選擇手動啟動 service mysqld start 檢測mysql...

ubuntu下安裝mysql環境

手動安裝mysql shell groupadd mysql shell useradd g mysql mysql shell gunzip mysql version.tar.gz tar xvf shell cd mysql version shell configure prefix usr...

外部鏈結ubuntu環境mysql

mysql 安裝環境 ubuntu 16.04 操作環境 win10 1.1 設定連線帳號和密碼 mysql u root root use mysql mysql update user set host where user root mysql select host,user from us...