$: vi /etc/mysql/my.cnf
遮蔽bind-address,預設是開啟的
----------
## instead of skip-networking the default
is now to listen only on
# localhost which is more compatible and
isnot less secure.
#bind-address = 127.0
.0.1
----------
#選擇mysql資料庫
mysql> use mysql
######
######
######
######
######
######
######
######
##**檢視現有mysql使用者**
######
######
######
######
######
######
######
######
#mysql> select user, host from user;
+------------------+--------------+
| user | host |
+------------------+--------------+
| root | 127.0
.0.1 |
| root | ::1 |
| root | iz25ljfuzffz |
| debian-sys-maint | localhost |
| root | localhost |
+------------------+--------------+
5 rows in set (0.00 sec)
######
######
######
######
######
######
######
######
######
##建立並授權外網可訪問的使用者,外網訪問密碼為123456,使用者為gzlogo
######
######
######
######
######
######
######
######
######
#mysql> grant all privileges on *.* to 'gzlogo'@'%' identified by '123456' with grant option;
query ok, 0 rows affected (0.00 sec)
######
######
######
######
######
######
######
######
######
#檢視建立結果
######
######
######
######
######
######
######
######
######
#mysql> select user, host from user;
+------------------+--------------+
| user | host |
+------------------+--------------+
| gzlogo | % |
| root | 127.0
.0.1 |
| root | ::1 |
| root | iz25ljfuzffz |
| debian-sys-maint | localhost |
| root | localhost |
+------------------+--------------+
6 rows in set (0.00 sec)
######
######
######
######
######
######
######
######
######
##重新整理許可權
######
######
######
######
######
######
######
######
######
#mysql> flush privileges;
query ok, 0 rows affected (0.00 sec)
mysql: [warning] using a password on
the command line inte***ce can be insecure.
welcome to
the mysql monitor. commands end
with ; or \g.
your mysql connection id
is39
server version: 5.5
.49-0ubuntu0.14
.04.1 (ubuntu)
oracle is a registered trademark of oracle corporation and/or
itsaffiliates. other names may be trademarks of their respective
owners.
type 'help;' or '\h' for help. type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
+--------------------+
3 rows in
set (0.04 sec)
mysql>
mysql 忘記密碼
$-> sudo service mysql stop
$-> mysqld_safe --user=mysql &
$-> mysql -u root mysql
mysql> update user set password=password('newpassword') where user=
'root';
mysql> flush privileges;
mysql> quit
$-> sudo service mysql restart
$-> sudo mysql -uroot
-penter password:
MySql設定外網訪問
mysql的root賬戶,我在連線時通常用的是localhost或127.0.0.1,公司的測試伺服器上的mysql也是localhost所以我想訪問無法訪問,測試暫停.解決方法如下 1,修改表,登入mysql資料庫,切換到mysql資料庫,使用sql語句檢視 select host,user fr...
Mysql 允許外網訪問
連線 mysql 之後,在 mysql 命令列中輸入以下指令碼就可以允許外網訪問了。update mysql.user set host where user root flush privileges mysql 預設是不允許外放訪問的,只允許 localhost 或 127.0.0.1 訪問。查...
設定mysql允許外網訪問
解決方法如下 1,修改表,登入mysql資料庫,切換到mysql資料庫,使用sql語句檢視 select host,user from user mysql u root pvmwaremysql use mysql mysql update user set host where user roo...