原作来源:https://github.com/aminglinux/daily_shell/blob/main/29.sh
根据我自己情况稍作修改
mysql下载地址:https://downloads.mysql.com/archives/community/
按照顺序执行逐行执行
注意执行过程的提示,报错需处理:
tar -xvf mysql-8.0.34-linux-glibc2.17-x86_64.tar sudo tar -xzvf mysql-8.0.34-linux-glibc2.17-x86_64.tar.gz -C /usr/local cd /usr/local/ sudo ln -s mysql-8.0.34-linux-glibc2.17-x86_64/ mysql sudo mkdir -p /data/mysql sudo useradd -s /sbin/nologin mysql sudo chown -R mysql:mysql /data/mysql sudo vim /etc/my.cnf # 写入如下内容 [mysql] port = 3306 socket = /tmp/mysql.sock [mysqld] user = mysql port = 3306 basedir = /usr/local/mysql datadir = /data/mysql socket = /tmp/mysql.sock pid-file = /data/mysql/mysqld.pid log-error = /data/mysql/mysql.err sudo apt-get update sudo apt-get install libaio-dev libtinfo5 libncurses5 sudo /usr/local/mysql/bin/mysqld --console --initialize-insecure --user=mysql sudo vim /usr/lib/systemd/system/mysqld.service #写如下内容 [Unit] Description=MYSQL server After=network.target [Install] WantedBy=multi-user.target [Service] Type=forking TimeoutSec=0 PermissionsStartOnly=true ExecStart=/usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf --daemonize $OPTIONS ExecReload=/bin/kill -HUP -$MAINPID ExecStop=/bin/kill -QUIT $MAINPID KillMode=process LimitNOFILE=65535 Restart=on-failure RestartSec=10 RestartPreventExitStatus=1 PrivateTmp=false sudo systemctl daemon-reload sudo systemctl enable mysqld sudo systemctl start mysqld sudo vim /etc/environment # 追加::/usr/local/mysql/bin # 重启系统 mysqladmin -uroot password '123456' # 开启远程连接 mysql -h 127.0.0.1 -u root -p # use mysql; # select host,user from user; # update user set host='%' where user='root'; # flush privileges; # select host,user from user;
标签:LTS,22,sudo,源码,mysqld,user,mysql,local,usr From: https://www.cnblogs.com/liujm-1820/p/ubuntu_server_binary_source_code_installation_mysql8.