ANS Documentation

Improve This Doc
  • Cloud
  • Domains and DNS management
  • Backup and High Availability
  • eCommerce Stacks
  • Security
  • Email
  • Monitoring and usage management
  • Networking
  • Operating systems
    • Linux
      • Basics
      • Apache
      • Control Panels
      • FTP
      • Magento
      • Miscellaneous
      • MySQL
      • NGINX
      • PHP
      • PHP-FPM
      • Setting up Websites
      • NFS
      • VPN
      • Percona
      • SSH
      • SSL
      • Git
      • Redis
      • Elasticsearch
      • MongoDB
      • Ncdu
    • VMware ESXi
    • Windows
  • Webcelerator
  • MyUKFast
  • Home >
  • Operating systems >
  • Linux >
  • MySQL >
  • Managing Databases and Users

Managing Databases and Users¶

This guide outlines some common tasks when it comes to managing your MySQL database and users.

Reset a normal user’s password¶

Run the following query to change a user’s password:

 UPDATE mysql.user SET Password = PASSWORD("ChooseAStrongPassword") WHERE User="username" ;
 exit

Reset the root user password¶

Losing your MySQL root password can be a problem. Luckily there is a fairly quick solution to reset the root password with minimal downtime.

Stop MySQL, and start it with the ‘–skip-grant-tables’ option so you can login without the password. Log into MySQL as root:

  service mysql stop
  mysqld --skip-grant-tables
  mysql -u root

Run the following query to change the root user password, then exit:

 UPDATE mysql.user SET Password = PASSWORD("ChooseAStrongPassword") WHERE User="root" ;
 exit

Stop and restart MySQL:

 service mysql stop
 service mysql start

Test logging in with the new password:

 mysql -u root -p

To change GRANTS, create new users or modify existing users¶

Use the commands below.

  CREATE DATABASE dbname;
  CREATE USER dbuser@00.00.00.00;
  SET PASSWORD FOR dbuser@00.00.00.00= PASSWORD("password");
  GRANT ALL PRIVILEGES ON dbname.* TO dbuser@00.00.00.00 IDENTIFIED BY 'password';
  FLUSH PRIVILEGES;

For a guide on a more common CLI commands, please do check out our MySQL Command Line Basics guide.

Next Article > MySQL Command Line Basics

  • Useful Links
  • SMB
  • Enterprise
  • Channel
  • Public Sector
  • ANS Data Centres
  • About ANS
  • Careers
  • Blog
  • Get in touch
  •  
  • Sales 0800 458 4545
  • Support 0800 230 0032
  • Get in touch

© ANS Group Limited | Terms and Conditions | Corporate Guidance | Sitemap
ANS Group Limited, registered in England and Wales, company registration number 03176761, registered office 1 Archway, Birley Fields, Manchester M15 5QJ