How do I get admin rights on MySQL database?

Rooty1985 :

I am in a bit of a situation and I am hoping someone might have the answer.

I have 'ready only' access to a MySQL remote database however the person who had full admin rights (and who set it up initially) has now passed away.

I now need to have access as I will be taking over a proportion of his role - I have the host url, port number as well as my own login details which are set as 'read only' so when I try to add a new user access is denied.

How do I get admin rights to this database?

Malkhazi Dartsmelidze :

First of all you need ssh access in your server and root user password on your system to sun sudo commands in your terminal.

After you log in in ssh server run following commands:

Stop MySql Service:

sudo /etc/init.d/mysql stop

Note: You may come across error while runing above command and try these. sudo systemctl stop mysqld or sudo service stop mysqld depending which system you are using. Main purpose is to stop mysql service.

Start MySQL without a password:

sudo mysqld_safe --skip-grant-tables &

Login as root without password:

mysql -u root

Then give your user admin privileges:

GRANT ALL PRIVILEGES ON database_name.table_name TO 'your_user'@'host'

Also you can change root user password by running these commands:

use mysql;
update user set authentication_string=PASSWORD("mynewpassword") where > > User='root';
flush privileges;
quit

Hope this helps.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=5663&siteId=1