Linux安裝配置mysql命令教程

2021-12-30 11:35:25 字數 2033 閱讀 5042

linux安裝配置mysql命令教程

-- 檢查是否安裝mysql,如果已安裝,以下都不要安裝了

rpm -qa | grep mysql-server

sudo yum -y install mysql-server

sudo vi /etc/my.cnf

在[mysqld]節點下修改default-character-set的編碼為utf8

default-character-set=utf8

-- 開機啟動配置

sudo chkconfig mysqld on

-- 檢視啟動狀態,第二個到第五個啟用狀態的話代表成功

sudo chkconfig --list mysql

-- 啟動mysql

sudo service mysqld start

mysql> select user,host from mysql.user;

-- 刪除匿名使用者

mysql> delete from mysql.user where user='';

mysql> flush privileges;

-- 開啟防火牆3306埠

sudo vi /etc/sysconfig/iptables

-a input -p tcp -m state --state new -m tcp --dport 3306 -j accept

-- 重啟防火牆

sudo service iptables restart

-- root使用者登入

mysql -u root

-- mysql -u root -p password

mysql> select user, host, password from mysql.user;

-- 修改root密碼

mysql> set password for root@localhost=password(''123456');

exit;

mysql -u root -p;

-- 刪除匿名使用者

mysql> select user, host from mysql.user;

mysql> delete from mysql.user where user='';

mysql> select user, host from mysql.user;

-- 重新整理許可權

mysql> flush privileges;

mysql> insert into mysql.user(host, user, password) values('localhost', 'yourname', password('yourpassword'));

mysql> flush privileges;

mysql> create database 'new_dbname' default character set utf8 collate utf8_general_ci;

-- 本地使用者賦予所有許可權

mysql> grant all privileges on new_dbname.* to yourname@localhost identified by 'yourpassword'

-- 給帳號開通外網所有許可權

mysql> grant all privileges on new_dbname.* to yourname@'%' identified by 'yourpassword'

-- 根據實際情況開通許可權

mysql> grant select,insert,updaate on new_dbname.* to yourname@'192.168.26.130' identified by 'yourpassword'

mysql> flush privileges;

mysql> exit

-- 以下是啟動,停用、重啟mysql的服務

sudo service mysqld start

sudo service mysqld stop

sudo service mysqld restart

linux安裝配置mysql

利用上篇已經配置好的yum來安裝mysql 1 安裝檢視有沒有安裝過 yum list installed mysql rpm qa grep mysql 2 檢視有沒有安裝包 yum list mysql 3 安裝mysql客戶端 yum install mysql 4 安裝mysql 伺服器端 ...

Linux安裝配置最新mysql

社群版本不要錢,企業版要錢,而community社群版對於我們已經夠用了,但是中途出了問題後,mysql不會負責,而企業版,mysql會負責幫你解決!tar xvf 壓縮包 c 要解壓到的路徑 預設解壓到當前資料夾。2.然後安裝兩個rpm安裝包,先安裝mysql client然後安裝mysql se...

linux下安裝配置mysql

安裝mysql yum install mysql server centos7不適用 centos7安裝mysql 啟動mysql service mysqld start 停止mysql service mysqld stop 重啟mysql service mysqld restart 配置m...