• mysql > les utilisateurs (user) et les droits

      log in to MySQL as the root user:

      mysql -u root -p
      puis taper le mot de passe

      CRÉER UN USER

      Add a user with password

      mysql -uroot -p
      CREATE USER 'nom'@'localhost' IDENTIFIED BY 'motdepasse';
      GRANT ALL PRIVILEGES ON *.* TO 'nom'@'localhost';
      FLUSH PRIVILEGES;
      exit;

       

      On peut restreindre les privilèges. Exemple, n’accorder que le SELECT :

       

      GRANT SELECT ON *.* TO 'username'@'localhost';

       

      Se logguer en tant que toto

      mysql -u toto -p
      puis taper le mot de passe

       

      To process the SQL script, type the following command. Replace username with the name of the user you created in step 1:

      mysql -u toto -p < example.sql

      The mysql program processes the script file statement by statement. When it finishes, the database and table are created, and the table contains the data you specified in the INSERT statements.

      LISTE DES USERS

      SELECT user FROM mysql.user GROUP BY user;

      SUPPRIMER UN USER

      DELETE FROM mysql.user WHERE user = 'nom';

      RÉINITIALISER LE MOT DE PASSE ROOT

      Log in to your account using SSH.

      You must run the commands in the following steps as the root user. Therefore, you can either log in directly as the root user (which is not recommended for security reasons), or use the su or sudo commands to run the commands as the root user.

      Stop the MySQL server using the appropriate command for your Linux distribution:

       

      service mysql stop

       

      Restart the MySQL server with the —skip-grant-tables option. To do this, type the following command:

       

      mysqld_safe --skip-grant-tables &

       

      Make sure you type the  (&) at the end of the command. This runs the command in the background and allows you to type the commands in the following steps.

      --skip-grant-tables is highly insecure, and should only be done for a brief period while you reset the password. The steps below show you how to stop the mysqld_safe server instance safely and start the MySQL server securely after you have reset the root password.

       

      Log into MySQL using the following command:

       

      mysql

       

      At the mysql> prompt, reset the password. To do this, type the following command, replacing new-password with the new root password:

       

      UPDATE mysql.user SET Password=PASSWORD('new-password') WHERE User='root';
      FLUSH PRIVILEGES;
      exit;

       

      Stop the MySQL server using the following command. You will be prompted to enter the new MySQL root password before the MySQL server shuts down:

       

      mysqladmin -u root -p shutdown

       

      Start the MySQL server normally. To do this, type the appropriate command for your Linux distribution:

       

      service mysql start

       

 

Aucun commentaire

 

Laissez un commentaire