Mysql

mysql遠程登入問題

Host is not allowed to connect to this MySQL server

遠程登入數據庫的時候,出現這個錯誤說明服務器不讓你root遠程登入

方法一:新建一個賬戶,然後把你的x庫的權限賦給這個用戶

假如Database:Test 
創建用戶:liuyang 密碼: 1234 

1.進入Mysql 

2.創建用戶:
CREATE USER liuyang IDENTIFIED BY '1234' ; 
3.分配權限:
grant insert,delete,update,select,drop,create,alter on Test.* to liuyang @"%" identified by "1234";   

GRANT ALL ON picture.* TO test IDENTIFIED BY "test";

方法二: 開放遠程權限

grant all privileges on *.* to 'root'@'%' identified by '1234' with grant option;

flush privileges;

grant option 不加(默認)情況下,該用戶是不能把這個權限授予給其他人的

添加後,該用戶可以將權限再授予給其他人

 

登入指令:

mysql -uliuyang -p1234  -h14.215.177.38 -p3306

 

Warning: Using a password on the command line interface can be insecure.

ERROR 1045 (28000): Access denied for user 'guang_wifi'@'59.33.112.18' (using pa
ssword: YES)    

//調整一下順序就可以了

mysql -h14.215.177.38 -p3306 -uliuyang -p1234  

 

mysql修改密碼:

方法一:沒有登入mysql

mysqladmin -u用戶名 -p舊密碼 password 新密碼

mysqladmin -u用戶名 -p password 新密碼

c:\mysql\bin>mysqladmin -uroot password "your old password"

enter new pwd

confim new pwd

當看到:Warning: Using a password on the command line interface can be insecure.  已經修改完成

方法二:登入mysql

mysql>use  mysql 

#新版本使用:5.7

mysql>update user set authentication_string=password('1234') where User='root';    //password(1234)  /('字符')

#老版本使用:5.6

mysql>update user set password=password(1234) where User='liuyang';    //password(1234)  /('字符')

#刷新權限

flush privileges; //重新加載權限表


方法三:跳過登入

在mysql的my.ini 配置文件中添加一行:skip-grant-tables

重啓mysql

1. 服務  services.msc
2. net start mysql 
3. net stop mysql 

直接不用密碼登入,執行方法二 ,修改  user='root'

 

mysql綠色安裝:

1.oracle官網下載mysql zip包

 


2.解壓,新建data文件夾(空),複製配置文件,進行配置

 

 

 

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.

[mysqld]
#skip-grant-tables 
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M

# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin

# These are commonly set, remove the # and set as required.
# basedir = .....
# datadir = .....
# port = .....
# server_id = .....
basedir ="F:\develpment\mysql\mysql-5.7.13-winx64"
datadir ="F:\develpment\mysql\mysql-5.7.13-winx64\data"


# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M 

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 

#服務端的編碼方式
character-set-server=utf8
[client]
#客戶端編碼方式,最好和服務端保存一致
loose-default-character-set=utf8
 
[WinMySQLadmin]  
Server = "F:\develpment\mysql\mysql-5.7.13-winx64\bin\mysqld.exe"

 

3.新建服務

cmd 中  cd到 mysql/bin   指令:

1) 使用-initialize生成隨機密碼,由於自己學習,使用-initialize-insecure生成空密碼。默認帳號root,後面的-user=mysql不更改(新建的data必須空,很重要!!!):”

mysqld --initialize-insecure --user=mysql  

2)安裝服務

 mysqld -install    (卸載服務: mysqld -remove)

3)開啓服務

 services.msc  找到mysql服務,點擊開啓

 

4)登入mysql

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章