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:

Both mysqld.service and mysql.service are aliases created for mariadb.service, this is because MariaDB is installed on your system instead of the standard MySQL. If you want to enable the MariaDB service instead of the MySQL service, you can use the following command to enable it:
 


systemctl enable mariadb.service
systemctl daemon-reload

Remote connection issues

Centos7.6 yum installs mysql_centos7.6 yum installs mysql_tenc1239's blog-CSDN blog

Guess you like

Origin blog.csdn.net/tenc1239/article/details/133208729