Debian install MySQL if use root remove command ‘sudo‘

To install MySQL on a Debian system, you can use the apt package manager. Here's how you can do it:

  1. Update Your System: Before installing any package, it's a good practice to update your system's package repository information:

    sudo apt update
  2. Install MySQL Server:

    sudo apt install default-mysql-server

    This will install the MySQL server and other required packages. During the installation, you will be prompted to set a password for the MySQL root user. Ensure you remember this password, as you'll need it to administer your MySQL server later.

  3. Start and Enable MySQL:

    The MySQL service should start automatically after installation. You can check its status with:

    sudo systemctl status mysql

    To ensure MySQL starts upon boot, enable it with:

    sudo systemctl enable mysql
  4. Securing MySQL Installation:

    MySQL comes with a script that can help with securing your installation:

    sudo mysql_secure_installation

    Follow the on-screen prompts. It will allow you to set the root password, remove anonymous users, disallow root login remotely, and remove the test databases. It's recommended to say 'yes' to all prompts.

  5. Accessing MySQL:

    To log in to the MySQL server as the root user:

    sudo mysql -u root -p

    Enter the root password when prompted.

  6. Install MySQL Client (Optional):

    If you want to have the MySQL client software installed so you can connect to other MySQL servers, run:

    sudo apt install default-mysql-client

That's it! You now have MySQL server installed and running on your Debian system. Remember, always backup your databases before making significant changes and always keep your server updated to receive the latest security patches.

Q:

root@:~# systemctl enable mysql
Synchronizing state of mysql.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable mysql
Failed to enable unit: Too many levels of symbolic links

a:

mysqld.service和mysql.service都是为mariadb.service创建的别名,这是因为您的系统上安装了MariaDB而不是标准的MySQL。如果您想启用MariaDB服务,而不是MySQL服务,可以使用以下命令来启用它:
 


systemctl enable mariadb.service
systemctl daemon-reload

远程连接问题

centos7.6 yum 安装mysql_centos7.6 yum安装mysql_tenc1239的博客-CSDN博客

猜你喜欢

转载自blog.csdn.net/tenc1239/article/details/133208729
今日推荐