国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
mysql5.6 linux下安裝筆記

由于現(xiàn)在要用mysql,以前一直用oracle ,現(xiàn)在下個(gè)mysql都要翻墻下載,官方網(wǎng)站都下不了,選擇之后都是windows版本。

最后找了個(gè)外國(guó)網(wǎng)站:http://fossies.org/linux/misc/mysql-5.6.25-linux-glibc2.5-x86_64.tar.gz/ 下載了最新版本的:mysql-5.6.25-linux-glibc2.5-x86_64.tar.gz


查看當(dāng)前centos版本和內(nèi)核,位數(shù)。

[root@localhost ~]#  cat /etc/redhat-release?。?etc/redhat-release配置文件用一行內(nèi)容來聲明 Red Hat 的名稱和版本號(hào)。 由 rc.local 使用.
CentOS release 6.5 (Final) ?。“l(fā)現(xiàn)我的是6.5版本。
[root@localhost ~]# cat /proc/version  ?。?4位系統(tǒng)
Linux version 2.6.32-431.el6.x86_64 (mockbuild@c6b8.bsys.dev.centos.org) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC) ) #1 SMP Fri Nov 22 03:15:09 UTC 2013
[root@localhost ~]# uname -a
Linux localhost.localdomain 2.6.32-431.el6.x86_64 #1 SMP Fri Nov 22 03:15:09 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux


一、把mysql壓縮包上傳到/usr/mysql 目錄下面。安裝目錄選擇/usr/local/mysql。

然后在網(wǎng)上找一篇安裝mysql的文章,最后參考了http://blog.csdn.net/zhanngle/article/details/41042631

-------------------------------------------

1.解壓tar包

cd /software
tar -xzvf mysql-5.6.21-linux-glibc2.5-x86_64.tar.gz  -- 更改對(duì)應(yīng)的包名mysql-5.6.25-linux-glibc2.5-x86_64.tar.gz
mv mysql-5.6.21-linux-glibc2.5-x86_64 mysql-5.6.21  --更改對(duì)應(yīng)的安裝目錄/usr/local/mysql

2.添加用戶與組

groupadd mysql
useradd -r -g mysql mysql
chown -R mysql:mysql mysql-5.6.21

3.安裝數(shù)據(jù)庫(kù)

su mysql
cd mysql-5.6.21/scripts
./mysql_install_db --user=mysql --basedir=/software/mysql-5.6.21 --datadir=/software/mysql-5.6.21/data
(新的:./mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data)
exit

這里可能會(huì)報(bào)錯(cuò):scripts/mysql_install_db: /usr/bin/perl: bad interpreter: No such file or directory。
需要安裝perl以及perl-devel.執(zhí)行命令:yum –y install perl perl-devel
4.配置文件

cd /software/mysql-5.6.21/support-files
cp my-default.cnf /etc/my.cnf
cp mysql.server /etc/init.d/mysql
vim /etc/init.d/mysql          #若mysql的安裝目錄是/usr/local/mysql,則可省略此步
修改文件中的兩個(gè)變更值
basedir=/software/mysql-5.6.21
datadir=/software/mysql-5.6.21/data

5.配置環(huán)境變量

vim /etc/profile
export MYSQL_HOME="/software/mysql-5.6.21"
export PATH="$PATH:$MYSQL_HOME/bin"
保存退出
. /etc/profile

6.添加自啟動(dòng)服務(wù)

chkconfig --add mysql
chkconfig mysql on

7.啟動(dòng)mysql

service mysql start

8.登錄mysql及改密碼與配置遠(yuǎn)程訪問

mysqladmin -u root password 'your_password'     #修改root用戶密碼,如果有問題mysqladmin: connect to server at 'localhost' failed -- http://blog.csdn.net/zl17/article/details/8589454
mysql -u root -p     #登錄mysql,需要輸入密碼
mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'your_password' WITH GRANT OPTION;     #允許root用戶遠(yuǎn)程訪問
mysql>FLUSH PRIVILEGES;     #刷新權(quán)限
mysql>exit

---------------------------2014/11/25 添加
又裝了一次此版本的mysql,發(fā)現(xiàn)root用戶不能登錄,提示沒權(quán)限。使用mysqld_safe 登進(jìn)去,發(fā)現(xiàn)user表居然是空的,沒有一個(gè)用戶,郁悶。
于是從其它地方導(dǎo)出了一份user表的sql語(yǔ)句,手動(dòng)插入了一個(gè)用戶,再登錄就可以了。
附:
忘記root密碼后,如何找回密碼
cd $MYSQL_HOME
./bin/mysqld_safe --basedir=/data/mysql-5.6.21 --datadir=/data/mysql-5.6.21/data --skip-grant-tables &
mysql -u root mysql
UPDATE user SET password=PASSWORD("new_password") WHERE user='root';
FLUSH PRIVILEGES;

二、按上面的文章安裝完之后

1、查詢當(dāng)前安裝的mysql版本

[root@localhost ~]# mysql -V
mysql  Ver 14.14 Distrib 5.6.25, for linux-glibc2.5 (x86_64) using  EditLine wrapper

進(jìn)入mysql、查看mysql版本
方法一:status;
方法二:select version();

2、Mysql啟動(dòng)、停止、重啟常用命令
a、啟動(dòng)方式
1、使用 service 啟動(dòng):
[root@localhost /]# service mysqld start (5.0版本是mysqld)
[root@szxdb etc]#
service mysql start (5.5.7版本是mysql)

2、使用 mysqld 腳本啟動(dòng):
/etc/inint.d/mysqld start

3、使用 safe_mysqld 啟動(dòng):
safe_mysqld&

b、停止
1、使用 service 啟動(dòng):
service mysqld stop

2、使用 mysqld 腳本啟動(dòng):
/etc/inint.d/mysqld stop

3、mysqladmin shutdown

c、重啟
1、使用 service 啟動(dòng):
service mysqld restart 
service mysql restart (5.5.7版本命令)

2、使用 mysqld 腳本啟動(dòng):
/etc/init.d/mysqld restart


三、賦予權(quán)限

(1)、創(chuàng)建用戶:

create user 'myuser'@'localhost' IDENTIFIED by '123456';

flush privileges;

(2)、創(chuàng)建數(shù)據(jù)庫(kù):

create database mydb;

flush privileges;

(3)、給用戶授權(quán)數(shù)據(jù)庫(kù)相關(guān)權(quán)限

grant all privileges on mydb.* to myuser@localhost identified by '123456';

flush privileges;

我用到的權(quán)限命令,簡(jiǎn)單說明,mydb為數(shù)據(jù)庫(kù)實(shí)例名,myuser為用戶名,后面對(duì)某個(gè)ip作對(duì)應(yīng)的權(quán)限控制。 
grant 為賦予權(quán)限,revoke為撤銷權(quán)限,賦予權(quán)限完之后要用flush privileges; 來刷新生效。

1、grant all on mydb.* to 'myuser'@'192.168.1.6';
2、grant select on mydb.* to 'myuser'@'192.168.1.%';
3、revoke all on mydb.*
from 'myuser'@'192.168.1.6';

查看用戶權(quán)限
show grants for 你的用戶
比如:
show grants for root@’localhost’;
mysql> use mysql;
Database changed
mysql> select user,host from user;

     具體參考:http://www.cnblogs.com/llsun/archive/2013/08/06/3240963.html

四、導(dǎo)入數(shù)據(jù)問題解決

ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...

1.執(zhí)行批量的MYSQL語(yǔ)句,例如備份恢復(fù)的時(shí)候,時(shí)間過長(zhǎng); 或者SQL語(yǔ)句過大或者語(yǔ)句中含有BLOB類似字段--我的是BLOB字段存放文件導(dǎo)致過大引起
對(duì)應(yīng):修改my.cnf中的wait_timeout和interactive_timeout變量 
在一些不便修改的情形下,如租用的空間,可以采取sql語(yǔ)句修改,如何做呢? 

(1)、如果是租用空間,無(wú)法修改數(shù)據(jù)庫(kù)參數(shù),那么臨時(shí)mysql語(yǔ)句設(shè)置,不過下次重新導(dǎo)入必須再設(shè)置:
#對(duì)當(dāng)前交互鏈接有效;  
mysql>set wait_timeout = someIntValue;  
#對(duì)后續(xù)起的交互鏈接有效;  
mysql>set interactive_timeout = someIntValue;  
mysql>set global max_allowed_packet=1000000000; ?。?/span>設(shè)置針對(duì)BLOB字段過大導(dǎo)入引起的問題


(2)、如果是自己的服務(wù)器,那么找到my.ini(windows下my.ini)文件,linux發(fā)現(xiàn)是/usr/local/mysql下的my.cnf文件。

添加一句max_allowed_packet=16M,如果不行將16M再加大
加大wait_timeout也可起一定作用
eg:
wait_timeout=2880000
interactive_timeout = 2880000
max_allowed_packet = 100M

應(yīng)用時(shí)記住重啟數(shù)據(jù)庫(kù)哦~~
除此之外,可能還有一些別的buffer_size的變量會(huì)影響到,也值得注意 
例如 
read_buffer_size 
read_rnd_buffer_size

重啟后查詢

mysql> show variables like '%timeout';
+-----------------------------+----------+
| Variable_name               | Value    |
+-----------------------------+----------+
| connect_timeout             | 10       |
| delayed_insert_timeout      | 300      |
| innodb_flush_log_at_timeout | 1        |
| innodb_lock_wait_timeout    | 50       |
| innodb_rollback_on_timeout  | OFF      |
| interactive_timeout         |
2880000  |
| lock_wait_timeout           | 31536000 |
| net_read_timeout            | 30       |
| net_write_timeout           | 60       |
| rpl_stop_slave_timeout      | 31536000 |
| slave_net_timeout           | 3600     |
| wait_timeout                |
2880000  |
+-----------------------------+----------+
12 rows in set (0.00 sec)

mysql> show VARIABLES like '%max_allowed_packet%';
+--------------------------+------------+
| Variable_name            | Value      |
+--------------------------+------------+
| max_allowed_packet       | 104857600  |
| slave_max_allowed_packet | 1073741824 |
+--------------------------+------------+
2 rows in set (0.00 sec)

五、安裝完之后訪問參考

http://blog.csdn.net/cuker919/article/details/44997923


六、啟動(dòng)應(yīng)用

啟動(dòng)應(yīng)用訪問發(fā)現(xiàn)應(yīng)用日志連接池報(bào):java.sql.SQLException: Access denied for user 'myuser'@'localhost' (using password: YES)

同時(shí)切換到linux,用該用戶試試:

[root@localhost ]# mysql -u myuser-p
Enter password:
ERROR 1045 (28000): Access denied for user 'myuser'@'localhost' (using password:

但發(fā)現(xiàn)mysql workbench用該用戶訪問一切正常,因?yàn)槲沂怯胢ysql workbench創(chuàng)建的用戶,但到linux又登錄不了。

下面是試錯(cuò)的過程,但既然后面可以登錄了

(1)、修改密碼

[root@localhost ]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 614
Server version: 5.6.25 MySQL Community Server (GPL)
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
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 ?。袚Q數(shù)據(jù)庫(kù)
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup
with -A

Database changed  
mysql> update user set password=password("123456") where user="root";  --更改root用戶密碼
Query OK, 3 rows affected (0.00 sec)
Rows matched: 5  Changed: 3  Warnings: 0

mysql> update user set password=password("123456") where user="myuser"; --更改myuser用戶密碼
Query OK, 4 rows affected (0.00 sec)
Rows matched: 5  Changed: 4  Warnings: 0

發(fā)現(xiàn)用這個(gè)命令修改密碼提示:ERROR 1146 (42S02): Table 'mydb.user' doesn't exist

參考:http://www.cnblogs.com/fly1988happy/archive/2011/12/15/2288554.html

update mysql.user set password=password('新密碼') where User="test" and Host="localhost";  -- 最后這樣更改才ok

mysql> exit  --退出

(2)、再登錄,還是報(bào)錯(cuò)

[root@localhost logs]# mysql -u myuser-p
Enter password:
ERROR 1045 (28000): Access denied for user 'myuser'@'localhost' (using password: 

(3)、再試錯(cuò)。

[root@localhost ]# /etc/init.d/mysql stop ?。V狗?wù)
Shutting down MySQL..... SUCCESS!
[root@localhost ]# /usr/bin/mysqld_safe --skip-grant-tables
-bash: /usr/bin/mysqld_safe: No such file or directory
[root@localhost ]# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
[1] 1791
[root@localhost ]# 150613 11:20:01 mysqld_safe Logging to '/usr/local/mysql/                                                                                                                               data/localhost.localdomain.err'.
150613 11:20:02 mysqld_safe Starting mysqld daemon with databases from /usr/loca                                                                                                                               l/mysql/data
^C  --按ctrl + c 退出
[root@localhost ]# mysqld_safe --user=mysql --skip-grant-tables --skip-networking
150613 11:21:27 mysqld_safe Logging to '/usr/local/mysql/data/localhost.localdom                                                                                                                               ain.err'.
150613 11:21:27 mysqld_safe A mysqld process already exists
[root@localhost ]# /etc/rc.d/init.d/mysql restart  --啟動(dòng)服務(wù)

[root@localhost ]# mysql -u myuser-p  -- 再登錄,既然可以了,然后應(yīng)用也可以登錄

(4)、總結(jié)

先登錄 mysql

# mysql -u root -p

mysql> use mysql   --切換

mysql> select host,user,Password from user;  --查看用戶和密碼情況,其實(shí)從這里就可以發(fā)現(xiàn)問題,不行就往下

# /etc/init.d/mysql stop
# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
# mysql -u root -p
mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root';
mysql> FLUSH PRIVILEGES;
mysql> quit
# /etc/init.d/mysqld restart
# mysql -u myuser -p

參考:http://www.bxl.me/zh-cn/2567.html  
http://blog.csdn.net/lyflower/article/details/6137021 
http://blog.csdn.net/vurtne_ye/article/details/26514499


本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
centOS7 安裝mysql數(shù)據(jù)庫(kù)
Mysql5.7 Linux編譯安裝教程
CentOS 7.4下使用yum安裝MySQL5.7.20 最簡(jiǎn)單的
Linux系統(tǒng)安裝MySQL(2020最新最詳細(xì))
linux配置mysql的表名忽略大小寫lower
MYSQL登錄錯(cuò)誤:mysqladmin: connect to server at 'localhost' failed
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服