Sohan Singh
Sohan Singh

Reputation: 23

unable to create database in mysql or via ssh

I m trying to create new database through mysql or ssh but on both m getting error

mysql : CREATE DATABASE porto;

Error : Access denied for user 'root'@'localhost' to database 'porto' on ssh : ERROR 1044 (42000): Access denied for user 'root'@'localhost' to database 'porto'

mysql> CREATE USER 'testuser'@'localhost' IDENTIFIED BY 'ecomaddon@42';

ERROR 1227 (42000): Access denied; you need (at least one of) the CREATE USER privilege(s) for this operation

mysql> SELECT User,Host From mysql.user;

ERROR 1142 (42000): SELECT command denied to user 'root'@'localhost' for table 'user'

Its problem of privilege but don't know how give root user all privilege ai had try all methods but got nothing.

Upvotes: 1

Views: 864

Answers (4)

Alfredo Lanzetta
Alfredo Lanzetta

Reputation: 314

You can try to access as root

mysql -h 127.0.0.1 -P 3306 -u root -p

If it still does not work follow this guide https://www.a2hosting.com/kb/developer-corner/mysql/managing-mysql-databases-and-users-from-the-command-line

Upvotes: 0

Sohan Singh
Sohan Singh

Reputation: 23

Thanks for reply to all i had solve i 1. first login to new user. 2. give access all to that users by update command . 3. drop root user and rename second user to root. main problem was : when we create root it didn't give grant_priv field access users .

Upvotes: 0

Bhushan
Bhushan

Reputation: 595

I think it's rights issue & It can be resolved by re configuring again. Here's a steps to reconfigure it.

  1. Stop the current MySQL server instance: sudo service mysql stop
  2. Use dpkg to re-run the configuration process that MySQL goes through on first installation. You will again be asked to set a root password. sudo dpkg-reconfigure mysql-server-5.5

Upvotes: 0

kapitan
kapitan

Reputation: 2222

you may be login as root but the root@localhost is not allowed for the actions you are executing.

mysql>CREATE USER 'root'@'localhost' IDENTIFIED BY 'enter_your_password_here';
mysql>exit

then try logging-in again

Upvotes: 0

Related Questions