mysql安装教程刘猿猿_mysql安装
linux上安裝
轉(zhuǎn)至https://blog.csdn.net/sndayyu/article/details/96745748
1.卸載mariadb
[root@localhost ~]# rpm -qa |grep mariadb
mariadb-libs-5.5.41-2.el7_0.x86_64
[root@localhost~]# rpm -qa | grep mariadb-server[root@localhost~]# rpm -e --nodeps mariadb-libs-5.5.41-2.el7_0.x86_64
[root@localhost~]# rpm -qa |grep mariadb
2、下載解壓
.windows上安裝簡單自行百度。這里介紹linux安裝流程
下載對應(yīng)版?,然后上傳到linux上
或者直接在linux:
[root@localhost ~]# cd /usr/local
[root@localhost local]# mkdir mysql
[root@localhost local]# cd mysql
[root@localhost mysql]# wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.27-1.el7.x86_64.rpm-bundle.tar
傳上去或者下載完成后解壓:
[root@localhost mysql]# tar -vxf mysql-5.7.27-1.el7.x86_64.rpm-bundle.tar
mysql-community-libs-5.7.27-1.el7.x86_64.rpm
mysql-community-embedded-devel-5.7.27-1.el7.x86_64.rpm
mysql-community-libs-compat-5.7.27-1.el7.x86_64.rpm
mysql-community-devel-5.7.27-1.el7.x86_64.rpm
mysql-community-embedded-compat-5.7.27-1.el7.x86_64.rpm
mysql-community-common-5.7.27-1.el7.x86_64.rpm
mysql-community-client-5.7.27-1.el7.x86_64.rpm
mysql-community-server-5.7.27-1.el7.x86_64.rpm
mysql-community-test-5.7.27-1.el7.x86_64.rpm
mysql-community-embedded-5.7.27-1.el7.x86_64.rpm
3.安裝下面四個
rpm -ivh mysql-community-common-5.7.27-1.el7.x86_64.rpm
rpm-ivh mysql-community-libs-5.7.27-1.el7.x86_64.rpm
rpm-ivh mysql-community-client-5.7.27-1.el7.x86_64.rpm
rpm-ivh mysql-community-server-5.7.27-1.el7.x86_64.rpm --nodeps
4.配置
1.如果是以root用戶mysql服務(wù),需要執(zhí)行以下初始化
mysqld --initialize --user=mysql
2.修改/etc/my.cnf 在末尾加上skip-grant-tables 表示可以沒密碼登錄,授權(quán)跳過。后面這行還是需要去掉的
3.重啟mysql服務(wù):systemctl restart mysqld
5.無密碼啟動并修改mysql密碼,刷新退出
mysql -u root
update mysql.user set authentication_string=password('1234') where user='root';
flush privileges;
quit;
6.刪除my.cnf中的最后一行、重啟服務(wù)
[root@localhost mysql]# systemctl stop mysqld
[root@localhost mysql]# systemctl start mysqld
[root@localhost mysql]# mysql-uroot -p1234
7.遠(yuǎn)程訪問權(quán)限
mysql>use mysql
ERROR1820 (HY000): You must reset your password using ALTER USER statement before executing thisstatement.
mysql> alter user 'root'@'localhost' identified by '1234';
Query OK,0 rows affected (0.00sec)
mysql>flush privileges;
Query OK,0 rows affected (0.00sec)
mysql>use mysql;
Reading table informationforcompletion of table and column names
You can turn offthis feature to get a quicker startup with -A
Database changed
mysql> update user set host='%' where user='root';
Query OK,1 row affected (0.00sec)
Rows matched:1 Changed: 1 Warnings: 0mysql>select host,user from user;+-----------+---------------+
| host | user |
+-----------+---------------+
| % | root |
| localhost | mysql.session |
| localhost | mysql.sys |
+-----------+---------------+
3 rows in set (0.00sec)
mysql>quit
Bye[root@localhost~]# systemctl stop mysqld;[root@localhost~]# systemctl start mysqld;
8.關(guān)閉防火墻? 測試遠(yuǎn)程連接
[root@localhost ~]# systemctl stop firewalld
windows上安裝(解壓版)
1.壞境變量path中添加mysql解壓后的bin目錄
2.在mysql的解壓目錄下(D:\dev\database\mysql-8.0.18-winx64)添加配置文件mysql.ini
[mysql]
# 設(shè)置mysql客戶端默認(rèn)字符集
default-character-set=utf8
[mysqld]
# 綁定IPv4
bind-address=0.0.0.0
# 設(shè)置端口號
port=3306
# 設(shè)置mysql的安裝目錄,即解壓目錄
basedir=D:\\dev\\database\\mysql-8.0.18-winx64
# 設(shè)置數(shù)據(jù)庫的數(shù)據(jù)存放目錄
datadir=D:\\dev\database\\mysql-8.0.18-winx64\\data
# 設(shè)置允許最大連接數(shù)
max_connections=200
# 設(shè)置允許連接失敗次數(shù)
max_connect_errors=10
# 設(shè)置服務(wù)端的默認(rèn)字符集
character-set-server=utf8
# 創(chuàng)建表使用的默認(rèn)存儲引擎
default-storage-engine=INNODB
# 使用“mysql_native_password”插件認(rèn)證
default_authentication_plugin=mysql_native_password
3.初始化mysql,管理員cmd: mysqld --initialize --console
4.安裝mysql服務(wù):mysqld --install mysql --defaults-file="D:\dev\database\mysql-8.0.18-winx64\mysql.ini"
5.退出:quit/exit
6.啟動服務(wù),管理員cmd:net start mysql(我的服務(wù)名是這個,也可以通過管理--服務(wù)界面手動開啟)
7.使用剛才的密碼登陸:mysql -uroot -p 密碼(登陸如果卡死的話,多重啟幾次服務(wù))
8.修改密碼,推出重登即可:ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '新密碼';
總結(jié)
以上是生活随笔為你收集整理的mysql安装教程刘猿猿_mysql安装的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: mysql做前端_MySQL 还可以这样
- 下一篇: mysql libs 5.1.71_用p