mysql初始化相關

2021-07-10 10:59:41 字數 2547 閱讀 6784

查詢mysql版本

mysql -v 或 在mysql中使用:status;

建立資料庫

create database weibo default charset utf8 collate utf8_general_ci;

顯示預設編碼設定

show variables like 『%char%』;

修改預設編碼:

set character_set_client=』utf8′;

set character_set_connection=』utf8′;

set character_set_database=』utf8′;

set character_set_results=』utf8′;

set character_set_server=』utf8′;

set character_set_system=』utf8′;

或直接修改 /etc/my.conf

[mysql]

default_character_set=utf8

[mysqld]

default_character_set=utf8

[client]

default_character_set=utf8

需要重啟mysql,重啟後 show variables like 『%char%』; 檢視預設編碼是否已修正

不區分大小寫

/etc/my.cnf 中的[mysqld]後新增新增lower_case_table_names=1

建立新使用者並賦予相應資料庫的操作許可權:

insert into mysql.user(host,user,password) values(「localhost」,」test」,password(「test」));

flush privileges;

grant all privileges on test.* to chenhaitao@localhost identified by 『test』;

修改使用者密碼:

update user set password=password(「test」) where user=』test』;

flush privileges;

開啟遠端

mysql -u root –p

mysql>use mysql;

mysql>update user set host = 『%』 where user = 『root』;

mysql>select host, user from user;

授權

授權root使用者遠端訪問資料庫,並設定密碼為123456

grant all privileges on . to 『root』@』%』 identified by 』123456′ with grant option;

授權ip位址為172.10.10.10的機器,可以以jk使用者的身份訪問資料庫,並設定密碼為123456

grant all privileges on . to 『jk』@』172.10.10.10』 identified by 』123456′ with grant option;

授權root使用者遠端訪問資料庫,

grant all privileges on . to 『root』@』%』 with grant option

授權生效

flush privileges

jdbc連線時,可以這個設定

xml:

?useunicode=true&characterencoding=utf-8

root 密碼丟失

mysql的my.cnf中設定

skip-grant-tables

無密碼登入後,重置密碼

group_concat

查詢:

show variables like 『%group_concat%』;

配置:

方法一:修改配置檔案中引數,新增 group_concat_max_len = 10240

方法二:在會話中實現,全域性或當前session中

set global group_concat_max_len=10240;

set session group_concat_max_len=10240;

max_allowed_packet

查詢 show variables like 『%max_allowed_packet%』;

方法一

在my.conf中設定 max_allowed_packet=16m

方法二

set global max_allowed_packet=20480;

mysql 初始化 MySQL初始化

port 3306 設定mysql的安裝目錄 basedir d php apmw mysql 8.0.17 設定mysql資料庫的資料的存放目錄 datadir d php apmw mysql 8.0.17 data 允許最大連線數 max connections 200 允許連線失敗的次數。m...

mysql 初始化序列 mysql初始化

mysqld nt remove mysql mysqld nt install mysqld initialize insecure user mysql mysqld install mysql root使用者拒絕連線 建立my.ini放在bin下 mysqld 設定3306埠 port 330...

mysql 初始化 mysql時間初始化

date forma t date,format 根據格式串format 格式化日期或日期和時間值date,返回結果串。可用date format 來格式化date 或datetime 值,以便得到所希望的格式。根據format字串格式化date值 s,s 兩位數字形式的秒 00,01,59 i 兩...