linux 安装mysql8.0
Last updated
2023-01-18 17:52:25
{"value":"### 1.\u4f7f\u7528\u7cfb\u7edf\u7684root\u8d26\u6237\n\n### 2.\u5207\u6362\u76ee\u5f55\n\n\u5207\u6362\u5230\u00a0\/use\/local \u76ee\u5f55\u4e0b\n\n### 3.\u4e0b\u8f7dmysql\u00a0\n\n> wget https:\/\/dev.mysql.com\/get\/Downloads\/MySQL-8.0\/mysql-8.0.21-linux-glibc2.12-x86_64.tar.xz\n\n\u6ce8\uff1a\u4e0b\u8f7d\u5931\u8d25\u68c0\u67e5\u4e00\u4e0bDNS\n\n### 4.\u89e3\u538bmysql\u00a0\n\n> tar xvJf mysql-8.0.21-linux-glibc2.12-x86_64.tar.xz\n\n#### \u91cd\u547d\u540d\u6587\u4ef6\u5939\u00a0\n\n> mv mysql-8.0.21-linux-glibc2.12-x86_64 mysql-8.0\n\n### 5.\u521b\u5efadata\u6587\u4ef6\u5939\n\n\u521b\u5efadata\u6587\u4ef6\u5939 \u5b58\u50a8\u6587\u4ef6\n\n> mkdir \/data\n\n### 6.\u521b\u5efa\u7528\u6237\u7ec4\u4ee5\u53ca\u7528\u6237\u548c\u5bc6\u7801\u00a0\u00a0\n\n> groupadd mysql\n\n>useradd -g mysql mysql\n\n### 7.\u6388\u6743\u7528\u6237\u00a0\n\n>chown -R mysql.mysql \/usr\/local\/mysql-8.0\n\n### 8.\u5207\u6362\u5230bin\u76ee\u5f55\u4e0b\n\n> cd bin\n\n### 9.\u521d\u59cb\u5316\u57fa\u7840\u4fe1\u606f\u00a0\n\n>.\/mysqld --user=mysql --basedir=\/usr\/local\/mysql-8.0 --datadir=\/usr\/local\/mysql-8.0\/data\/ --initialize\n\n![](https:\/\/97yw3pix.hk03.1112oss.com\/TechnicalQA%2F%E6%96%87%E6%A1%A3%2Fweek13%2Flinux%20%E5%AE%89%E8%A3%85mysql8.0%2F1.png)\n\n\u7ea2\u6846\u5185\u7684\u662f\u4e34\u65f6\u5bc6\u7801\n\n### 10.\u7f16\u8f91my.cnf\u6587\u4ef6\u00a0\u00a0\n\n>vi \/etc\/my.cnf\n\n#### \u6ce8\u91camysqld_safe\u00a0 \u4fee\u6539\u4fe1\u606f\u00a0\u00a0 \u00a0\n\n>basedir=\/usr\/local\/mysql-8.0\/\n>datadir=\/usr\/local\/mysql-8.0\/data\/\n>socket=\/tmp\/mysql.sock\n>character-set-server=UTF8MB4\n\n![](https:\/\/97yw3pix.hk03.1112oss.com\/TechnicalQA%2F%E6%96%87%E6%A1%A3%2Fweek13%2Flinux%20%E5%AE%89%E8%A3%85mysql8.0%2F2.png)\n\n### 11.\u6dfb\u52a0mysqld\u670d\u52a1\u5230\u7cfb\u7edf\u00a0\u00a0\n\n>cp -a .\/support-files\/mysql.server \/etc\/init.d\/mysql\n\n### 12.\u6388\u6743\u4ee5\u53ca\u6dfb\u52a0\u670d\u52a1\u00a0 \u00a0 \u00a0\n\n>chmod +x \/etc\/init.d\/mysql\n\n>chkconfig --add mysql\n\n### 13.\u542f\u52a8mysql\u00a0\n\n>service mysql start\n\n### 14.\u67e5\u770b\u542f\u52a8\u72b6\u6001\u00a0\n\n>service mysql status\n\n![](https:\/\/97yw3pix.hk03.1112oss.com\/TechnicalQA%2F%E6%96%87%E6%A1%A3%2Fweek13%2Flinux%20%E5%AE%89%E8%A3%85mysql8.0%2F3.png)\n\n### 15.\u5c06mysql\u547d\u4ee4\u6dfb\u52a0\u5230\u670d\u52a1\n\n>ln -s \/usr\/local\/mysql-8.0\/bin\/mysql \/usr\/bin\n\n### 16.\u767b\u5f55mysql\n\n\u767b\u5f55mysql\uff0c\u5bc6\u7801\u4f7f\u7528\u4e4b\u524d\u968f\u673a\u751f\u6210\u7684\u5bc6\u7801\n\n>mysql -uroot -p \n\n### 17.\u4fee\u6539root\u5bc6\u7801\n\n\u6848\u4f8b\u5176\u4e2d123456\u662f\u65b0\u7684\u5bc6\u7801,\u53ef\u81ea\u884c\u8bbe\u7f6e\n\n>ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';\n\n![](https:\/\/97yw3pix.hk03.1112oss.com\/TechnicalQA%2F%E6%96%87%E6%A1%A3%2Fweek13%2Flinux%20%E5%AE%89%E8%A3%85mysql8.0%2F4.png)\n\n### 18.\u6267\u884c\u00a0flush privileges\n\n\u6267\u884c\u00a0flush privileges;\u00a0 \u4f7f\u5bc6\u7801\u751f\u6548\n\n>flush privileges;\n\n![](https:\/\/97yw3pix.hk03.1112oss.com\/TechnicalQA%2F%E6%96%87%E6%A1%A3%2Fweek13%2Flinux%20%E5%AE%89%E8%A3%85mysql8.0%2F5.png)\n\n### 19.\u9009\u62e9mysql\u6570\u636e\u5e93\u00a0\n\n>use mysql;\n\n![](https:\/\/97yw3pix.hk03.1112oss.com\/TechnicalQA%2F%E6%96%87%E6%A1%A3%2Fweek13%2Flinux%20%E5%AE%89%E8%A3%85mysql8.0%2F6.png)\n\n### 20.\u4fee\u6539\u8fdc\u7a0b\u8fde\u63a5\u5e76\u751f\u6548\u00a0\u00a0\u00a0\n\n>update user set host='%' where user='root';\n\n>flush privileges;\n\n![](https:\/\/97yw3pix.hk03.1112oss.com\/TechnicalQA%2F%E6%96%87%E6%A1%A3%2Fweek13%2Flinux%20%E5%AE%89%E8%A3%85mysql8.0%2F8.png)"}