july
july
发布于 2023-06-24 / 14 阅读
0

Debian安装MySQL8.0.33

安装

安装前置依赖

aptitude install libssl libmecab libnuma multiarch-support psmisc

#下载仓库没有的依赖
wget http://snapshot.debian.org/archive/debian/20190501T215844Z/pool/main/g/glibc/multiarch-support_2.28-10_amd64.deb

wget http://snapshot.debian.org/archive/debian/20230609T030206Z/pool/main/o/openssl/libssl1.1_1.1.1n-0%2Bdeb11u5_amd64.deb
   
sudo dpkg -i multiarch-support*.deb
sudo dpkg -i libssl1.1.1*.deb

下载

wget https://downloads.mysql.com/archives/get/p/23/file/mysql-server_8.0.33-1debian11_amd64.deb-bundle.tar

解压压缩包

tar xvf mysql-server_8.0.33-1debian11_amd64.deb-bundle.tar

依此安装

sudo dpkg-preconfigure mysql-community-server_*.deb

sudo dpkg -i mysql-{common,community-client-plugins,community-client-core,community-client,client,community-server-core,community-server,server}_*.deb

验证是否在运行

systemctl status mysql

查看安装版本

mysqladmin --version

mysqladmin  Ver 8.0.33 for Linux on x86_64 (MySQL Community Server - GPL)

初始化MySQL

初始化mysql账户密码

# 避免使用mysql_secure_installation初始化安装出现下面循环提示
.. Failed! Error: SET PASSWORD has no significance for user 'root'@'localhost' as the authentication method used doesn't store authentication data in the MySQL server. Please consider using ALTER USER instead if you want to change authentication parameters.

#登陆账户
root@localhost:~# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 8.0.33 MySQL Community Server - GPL

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

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>  ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password by 'xxxxxxx';
Query OK, 0 rows affected (0.00 sec)

mysql> exit;
Bye
root@localhost:~#

使用mysql_secure_installation执行安全化安装

root@localhost:~# sudo mysql_secure_installation

Securing the MySQL server deployment.

Enter password for user root: 
The 'validate_password' component is installed on the server.
The subsequent steps will run with the existing configuration
of the component.
Using existing password for root.

Estimated strength of the password: 100 
Change the password for root ? ((Press y|Y for Yes, any other key for No) : y

New password: 

Re-enter new password: 

Estimated strength of the password: 100 
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.


Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Success.

By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.


Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
 - Dropping test database...
Success.

 - Removing privileges on test database...
Success.

Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.

All done! 

登陆验证

mysql -uroot -p