I've been scratching my head for a day and probably read so many articles and on how can I allow my MariaDB to listen to remote connections. Unfortunately getting the below error.
Host 'xxx.xxx.xxx.xxx' is not allowed to connect to this MariaDB server.
I also read this StackOverflow question, anotherQuestion and successfully able to create the new user and grant all permission with following MySQL query.
CREATE USER 'ahsensaeed'#'%' IDENTIFIED BY 'my_password';
GRANT ALL PRIVILEGES ON *.* TO 'ahsensaeed'#'%' WITH GRANT OPTION;
And below is my ahsensaeed user grants.
MariaDB [mysql]> show grants for 'ahsensaeed'#'%';
+--------------------------------------------------------------------------------------------------------------------------------------+
| Grants for ahsensaeed#% |
+--------------------------------------------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'ahsensaeed'#'%' IDENTIFIED BY PASSWORD '*F794ABE2A12665587C6B6D8B61E2F7E987711AFA' WITH GRANT OPTION |
+--------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
In the end, I just flush the privileges and after that, I go to my MariaDB configuration file and edit it. Below is the path where my MariaDB conf file placed.
/etc/mysql/mariadb.conf.d/50-server.cnf
The following shows my MariaDB file block.
[mysqld]
#
# * Basic Settings
#
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address = 0.0.0.0
.....
.....
and then I just restart the mysql service via /etc/init.d/mysql restart. I also open the 3306 port on my client for mysql.
When the above solution not works I also add the bind-address = 0.0.0.0 in /etc/mysql/conf.d/mysql.cnf file, but still it failed with error.
The following shows how I requesting for MariaDB database from my server.
-> mysql -uahsensaeed -p -h hostIp
and then I got the below error.
ERROR 1130 (HY000): Host 'hostIp' is not allowed to connect to this MariaDB server
Edit Added the host and user data.
MariaDB [(none)]> select User,Host from mysql.user;
+------------+-----------+
| User | Host |
+------------+-----------+
| ahsensaeed | % |
| root | localhost |
+------------+-----------+
2 rows in set (0.00 sec)
Any help would be appreciated.
This worked for me (I`m using Ubuntu 18.04 as virtual machine and Windows 10 with Vagrant):
sudo mysql -e "CREATE DATABASE {db_name};"
sudo mysql -e "CREATE USER {user_name}#localhost IDENTIFIED BY '{password}';"
sudo mysql -e "UPDATE mysql.user SET Host='%' WHERE User='{user_name}';"
sudo mysql -e "GRANT ALL PRIVILEGES ON {db_name}.* TO '{user_name}'#'%';"
sudo mysql -e "FLUSH PRIVILEGES;"
sudo systemctl restart apache2
sudo systemctl restart mariadb
After that, you should edit the file:
/etc/mysql/mariadb.conf.d/50-server.cnf
And set bind-address property to your hostIP address or just comment this line out.
Finally, run commands:
sudo systemctl restart apache2
sudo systemctl restart mariadb
I hope this will suit your needs
Related
when I installed mysql server into ubuntu machine using this command
sudo apt-get install mysql-client mysql-server
the command is executed successfully but during the installation mysql not asked me about password , so I can not login to mysql except as root user , in other words if I writing into command line this command
sudo mysql -uroot -p
I can login to mysql even if I changed password every time , server does not matter about password if I used sudo . so how can I solve this problem (set new password)
when I logged to mysql I tried to change password from mysql.user table using this query
mysql> UPDATE mysql.user SET Password= PASSWORD('rootroot') WHERE User = 'root';
but there is no Password column into mysql.user table
The reason is that recent Ubuntu installation (maybe others also), mysql is using by default the UNIX auth_socket plugin.
Basically means that: db_users using it, will be "auth" by the system user credentias. You can see if your root user is set up like this by doing the following:
$ sudo mysql -u root # I had to use "sudo" since is new installation
mysql> USE mysql;
mysql> SELECT User, Host, plugin FROM mysql.user;
+------------------+-----------------------+
| User | plugin |
+------------------+-----------------------+
| root | auth_socket |
| mysql.sys | mysql_native_password |
| debian-sys-maint | mysql_native_password |
+------------------+-----------------------+
As you can see in the query, the root user is using the auth_socket plugin
There are 2 ways to solve this:
You can set the root user to use the mysql_native_password plugin
You can create a new db_user with you system_user (recommended)
Option 1:
$ sudo mysql -u root # I had to use "sudo" since is new installation
mysql> USE mysql;
mysql> UPDATE user SET plugin='mysql_native_password' WHERE User='root';
mysql> FLUSH PRIVILEGES;
mysql> exit;
$ service mysql restart
MySQL by default create a password for root#hostname
I tried finding the password from directories of MySQL, but was not successful.
So, I tried resetting password. I followed the following steps.
# Stop MySQL
sudo service mysql stop
# Make MySQL service directory.
sudo mkdir /var/run/mysqld
# Give MySQL user permission to write to the service directory.
sudo chown mysql: /var/run/mysqld
# Start MySQL manually, without permission checks or networking.
sudo mysqld_safe --skip-grant-tables --skip-networking &
# Log in without a password.
mysql -uroot mysql
**Update password for root**
UPDATE mysql.user SET authentication_string=PASSWORD('YOURNEWPASSWORD'), plugin='mysql_native_password' WHERE User='root' AND Host='%';
EXIT;
# Turn off MySQL.
sudo mysqladmin -S /var/run/mysqld/mysqld.sock shutdown
# Start the MySQL service normally.
sudo service mysql start
Otherwise, please refer this link
I think you should use authentication_string instead of Password.
Localhost connection is enabled in MySQL.
But Remote(My laptop) access is disabled
Can't connect to MySQL server on "host" (10061)`.
My port always open 3306.
Here is my config file (/etc/mysql/my.cnf) :
#bind-address 0.0.0.0
!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/
And MySQL status is :
mysql start/running, process 15204
To allow remote access to MySQL, you have to comment out bind-address (you did) and skip-networking in the configuration file.
Next, you have to make sure the user is allowed remote access. Check your user with this:
SELECT User, Host FROM mysql.user;
If your user here has '127.0.0.1' or 'localhost' listed as host, you don't have remote access.
Change this with:
UPDATE mysql.user SET HOST='%' WHERE User='__here_your_username';
Flush privileges:
FLUSH PRIVILEGES;
The '%' is a wildcard for 'all hosts'.
To Allow remote access to MySQL installed on a Ubuntu, you will have to access the file at this location:
/etc/mysql/mysql.conf.d/mysqld.cnf
There, you comment out the following line: bind-address = 127.0.0.1
basically to change: bind-address = 127.0.0.1
to: #bind-address = 127.0.0.1
Now you either restart the computer or just the mySQL service using the follwing command:
sudo /etc/init.d/mysql restart
The following worked for me.
SELECT User, Host FROM mysql.user;
UPDATE mysql.user SET HOST='%' WHERE User='root';
UPDATE mysql.user SET HOST='%' WHERE User='administrator';
FLUSH PRIVILEGES;
Then,
sudo gedit /etc/mysql/mysql.conf.d/mysqld.cnf
Change
bind-address = 127.0.0.1 to: #bind-address = 127.0.0.1
save the file.
reboot server/restart the MySQL
In my case, installed LAMP stack on Oracle VM of Ubuntu 18.04
Here's my updateto mysql config file: /etc/mysql/mysql.conf.d/mysqld.cnf
Before:
bind-address = 127.0.0.1
After:
# bind-address = 127.0.0.1
# comment out bind-address to test remote access
Ensure your user can access from remote host
sudo mysql -u root -p
Enter your password, then issue the command
mysql> SELECT user,authentication_string,plugin,host FROM mysql.user;
+------------------+-------------------------------------------+-----------------------+--------------+
| user | authentication_string | plugin | host |
+------------------+-------------------------------------------+-----------------------+--------------+
| newuser | *9ACA980716AE084BCA56C59D19F3CEB7BB87B139 | mysql_native_password | 192.168.x.x |
| newuser | *9ACA980716AE084BCA56C59D19F3CEB7BB87B139 | mysql_native_password | localhost |
This works for me, good luck.
That bind-address = 127.0.0.1 config option means that your mysql server only accepts connections from the localhost, which is your actual CentOS machine. Make sure to set bind-address = 0.0.0.0
For anyone else who is hosting the MySQL on a Raspberry Pi 3 the file you are looking for is in
etc/mysql/mariadb.conf.d/50-server.cnf
You still need to follow the prior steps like Nesan Mano stated above though by commenting out
bind-address = 127.0.0.1
Hopefully this helps someone else from spending as much as time as I did for what appeared to be a missing line.
Cannot login to MySQL database after fresh install with root ID and empty/no password like other older MySQL versions do
There's so many answers out there saying to reinstall mysql or use some combo of
mysqld_safe --skip-grant-tables
and / or
UPDATE mysql.user SET Password=PASSWORD('password')
and / or something else ...
... None of it was working for me
Here's what worked for me, on Ubuntu 18.04, from the top
With special credit to this answer for digging me out of the frustration on this ...
$ sudo apt install mysql-server
$ sudo cat /etc/mysql/debian.cnf
Note the lines which read:
user = debian-sys-maint
password = blahblahblah
Then:
$ mysql -u debian-sys-maint -p
Enter password: // type 'blahblahblah', ie. password from debian.cnf
mysql> USE mysql
mysql> SELECT User, Host, plugin FROM mysql.user;
+------------------+-----------+-----------------------+
| User | Host | plugin |
+------------------+-----------+-----------------------+
| root | localhost | auth_socket |
| mysql.session | localhost | mysql_native_password |
| mysql.sys | localhost | mysql_native_password |
| debian-sys-maint | localhost | mysql_native_password |
+------------------+-----------+-----------------------+
4 rows in set (0.00 sec)
mysql> UPDATE user SET plugin='mysql_native_password' WHERE User='root';
mysql> COMMIT; // When you don't have auto-commit switched on
Either:
mysql> ALTER USER 'root'#'localhost' IDENTIFIED BY 'new_password';
Or:
// For MySQL 5.7+
UPDATE mysql.user SET authentication_string=PASSWORD('new_password') where user='root';
Then:
mysql> FLUSH PRIVILEGES;
mysql> COMMIT; // When you don't have auto-commit switched on
mysql> EXIT
$ sudo service mysql restart
$ mysql -u root -p
Enter password: // Yay! 'new_password' now works!
After you installed MySQL-community-server 5.7 from fresh on linux, you will need to find the temporary password from /var/log/mysqld.log to login as root.
grep 'temporary password' /var/log/mysqld.log
Run mysql_secure_installation to change new password
ref: http://dev.mysql.com/doc/refman/5.7/en/linux-installation-yum-repo.html
MySQL 5.7 changed the secure model: now MySQL root login requires a sudo
The simplest (and safest) solution will be create a new user and grant required privileges.
1. Connect to mysql
sudo mysql --user=root mysql
2. Create a user for phpMyAdmin
CREATE USER 'phpmyadmin'#'localhost' IDENTIFIED BY 'some_pass';
GRANT ALL PRIVILEGES ON *.* TO 'phpmyadmin'#'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
Reference - https://askubuntu.com/questions/763336/cannot-enter-phpmyadmin-as-root-mysql-5-7
MySQL server 5.7 was already installed by default on my new Linux Mint 19.
But, what's the MySQL root password? It turns out that:
The default installation uses auth_socket for authentication, in lieu of passwords!
It allows a password-free login, provided that one is logged into the Linux system with the same user name. To login as the MySQL root user, one can use sudo:
sudo mysql --user=root
But how to then change the root password? To illustrate what's going on, I created a new user "me", with full privileges, with:
mysql> CREATE USER 'me'#'localhost' IDENTIFIED BY 'my_new_password';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'me'#'localhost' WITH GRANT OPTION;
mysql> FLUSH PRIVILEGES;
Comparing "me" with "root":
mysql> SELECT user, plugin, HEX(authentication_string) FROM mysql.user WHERE user = 'me' or user = 'root';
+------+-----------------------+----------------------------------------------------------------------------+
| user | plugin | HEX(authentication_string) |
+------+-----------------------+----------------------------------------------------------------------------+
| root | auth_socket | |
| me | mysql_native_password | 2A393846353030304545453239394634323734333139354241344642413245373537313... |
+------+-----------------------+----------------------------------------------------------------------------+
Because it's using auth_socket, the root password cannot be changed: the SET PASSWORD command fails, and mysql_secure_installation desn't attain anything...
==> To zap this alternate authentication mode and return the MySQL root user to using passwords:
ALTER USER 'root'#'localhost' IDENTIFIED WITH mysql_native_password BY 'SOME_NEW_ROOT_PASSWORD';
A good explanation.
More details from the MySQL manual.
In case you want to install mysql or percona unattended (like in my case ansible), you can use following script:
# first part opens mysql log
# second part greps lines with temporary password
# third part picks last line (most recent one)
# last part removes all the line except the password
# the result goes into password variable
password=$(cat /var/log/mysqld.log | grep "A temporary password is generated for" | tail -1 | sed -n 's/.*root#localhost: //p')
# setting new password, you can use $1 and run this script as a file and pass the argument through the script
newPassword="wh#teverYouLikE"
# resetting temporary password
mysql -uroot -p$password -Bse "ALTER USER 'root'#'localhost' IDENTIFIED BY '$newPassword';"
MySQL 5.7 or newer generates a default temporary password after fresh install.
To use MySQL first you would be required to get that password from the log file which is present at the /var/log/mysqld.log. So follow the following process:
grep 'temporary password' /var/log/mysqld.log
mysql_secure_installation
The second command is required to change the password for MySQL and also to make certain other changes like removing temporary databases, allow or disallow remote access to root user, delete anonymous users etc…
It seems things were designed to avoid developers to set the root user, a better solution would be:
sudo mysql -u root
Then create a normal user, set a password, then use that user to work.
create user 'user'#'localhost' identified by 'user1234';
grant all on your_database.* to 'user'#'localhost';
select host, user from mysql.user;
Then try to access:
mysql -u user -p
Boom!
None of these answers worked for me on Ubuntu Server 18.04.1 and MySQL 5.7.23. I spent a bunch of time trying and failing at setting the password and auth plugin manually, finding the password in logs (it's not there), etc.
The solution is actually super easy:
sudo mysql_secure_installation
It's really important to do this with sudo. If you try without elevation, you'll be asked for the root password, which you obviously don't have.
After a lot of try, I could reset the default password with the following commands (Ubuntu and derivatives):
sudo -i
mkdir -p /var/run/mysqld
chown mysql:mysql /var/run/mysqld
/etc/init.d/mysql stop
mysqld_safe --skip-grant-tables &
mysql -uroot
use mysql;
update user set authentication_string=password('YOURPASSWORD') where user='root';
update user set plugin="mysql_native_password" where User='root';
flush privileges;
quit;
sudo /etc/init.d/mysql stop
sudo /etc/init.d/mysql start
Sometimes, even after typed in the terminal
mkdir -p /var/run/mysqld
chown mysql:mysql /var/run/mysqld
/etc/init.d/mysql stop
mysqld_safe --skip-grant-tables &
I got the error that the mysqld don't exists. So, quit, and type the same commands again.
And the final command
sudo /etc/init.d/mysql start
Sometimes doesn't work. Only after restart the computer.
I just installed Linux Mint 19 (based on Ubuntu 18.04) on my machine. I installed MySQL 5.7 from the repo (sudo apt install mysql-server) and surprisingly during installation, the setup didn't prompt to enter root password. As a result I wasn't able to login into MySQL. I googled here and there and tried various answers I found on the net, including the accepted answer above. I uninstalled (purging all dpkgs with mysql in its name) and reinstalled again from the default Linux Mint repositories. NONE works.
After hours of unproductive works, I decided to reinstall MySQL from the official page. I opened MySQL download page (https://dev.mysql.com/downloads/repo/apt) for apt repo and clicked Download button at the bottom right.
Next, run it with dpkg:
sudo dpkg -i mysql-apt-config_0.8.10-1_all.deb
At the installation setup, choose the MySQL version that you'd like to install. The default option is 8.0 but I changed it to 5.7. Click OK to quit. After this, you have a new MySQL repo in your Software Sources.
Update your repo:
sudo apt update
Finally, install MySQL:
sudo apt install mysql-server
And now I was prompted to provide root password! Hope it helps for others with this same experience.
As of Ubuntu 20.04 with MySql 8.0 : you can set the password that way:
login to mysql with sudo mysql -u root
change the password:
USE mysql;
UPDATE user set authentication_string=NULL where User='root';
FLUSH privileges;
ALTER USER 'root'#'localhost' IDENTIFIED WITH caching_sha2_password BY 'My-N7w_And.5ecure-P#s5w0rd';
FLUSH privileges;
QUIT
now you should be able to login with mysql -u root -p (or to phpMyAdmin with username root) and your chosen password.
P,S:
You can also login with user debian-sys-maint, the password is written in the file /etc/mysql/debian.cnf
To do it in non interactive mode (from a script):
systemctl start mysqld
MYSQL_ROOT_TMP_PSW=$(grep 'temporary password' $logpath/mysqld.log |sed "s|.*: ||")
## POPULATE SCHEMAS WITH ROOT USER
/usr/bin/mysql --connect-expired-password -u root -p${MYSQL_ROOT_TMP_PSW} < "$mysql_init_script"
Here's the head of the init script
SET GLOBAL validate_password_policy=LOW;
FLUSH privileges;
SET PASSWORD = PASSWORD('MYSQL_ROOT_PSW');
FLUSH privileges;
GRANT ALL PRIVILEGES ON *.* TO 'root'#'%';
FLUSH privileges;
...
Then restart the service systemctl restart mysqld
In my case the data directory was automatically initialized with the --initialize-insecure option. So /var/log/mysql/error.log does not contain a temporary password but:
[Warning] root#localhost is created with an empty password ! Please
consider switching off the --initialize-insecure option.
What worked was:
shell> mysql -u root --skip-password
mysql> ALTER USER 'root'#'localhost' IDENTIFIED BY 'new_password';
Details: MySQL 5.7 Reference Manual > 2.10.4 Securing the Initial MySQL Account
I to was experiencing the same problem and the only thing I was able to do to make it work was to go this route:
drop user admin#localhost;
flush privileges;
create user admin#localhost identified by 'admins_password'
This allowed me to recreate my username and enter a password for the user name.
I've installed MySQL server on a remote Ubuntu machine. The root user is defined in the mysql.user table this way:
mysql> SELECT host, user, password FROM user WHERE user = 'root';
+------------------+------+-------------------------------------------+
| host | user | password |
+------------------+------+-------------------------------------------+
| localhost | root | *xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
| ip-10-48-110-188 | root | *xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
| 127.0.0.1 | root | *xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
| ::1 | root | *xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
+------------------+------+-------------------------------------------+
I can access with user root from the same remote machine command-line interface using the standard mysql client. Now I want to allow root access from every host on the internet, so I tried adding following row (it's an exact duplicate of the first row from previous dump, except for the host column):
mysql> SELECT host, user, password FROM user WHERE host = '%';
+------------------+------+-------------------------------------------+
| host | user | password |
+------------------+------+-------------------------------------------+
| % | root | *xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
+------------------+------+-------------------------------------------+
But my client on my personal PC continues to tell me (I obscured the server IP):
SQL Error (2003): Can't connect to MySQL server on '46.x.x.x' (10061)
I can't tell if it's a authentication error or a network error. On the server firewall I enabled port 3306/TCP for 0.0.0.0/0, and that's ok for me...
Update:
As mentioned in the comments, since MySql 8 you need to first explicitly create the user, so the command will look like:
CREATE USER 'root'#'%' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON *.* TO 'root'#'%' WITH GRANT OPTION;
Original answer:
There's two steps in that process:
a) Grant privileges. As root user execute with this substituting 'password' with your current root password :
GRANT ALL PRIVILEGES ON *.* TO 'root'#'%' IDENTIFIED BY 'password';
b) bind to all addresses:
The easiest way is to comment out the line in your my.cnf file:
#bind-address = 127.0.0.1
and restart mysql
service mysql restart
By default it binds only to localhost, but if you comment the line it binds to all interfaces it finds. Commenting out the line is equivalent to bind-address=*.
To check where mysql service has binded execute as root:
netstat -tupan | grep mysql
Update For Ubuntu 16:
Config file is (now)
/etc/mysql/mysql.conf.d/mysqld.cnf
(at least on standard Ubuntu 16)
Run the following query:
use mysql;
update user set host='%' where host='localhost'
NOTE: Not recommended for production use.
MYSQL 8.0 - open mysql command line client
GRANT ALL PRIVILEGES ON *.* TO 'root'#'localhost';
use mysql
UPDATE mysql.user SET host='%' WHERE user='root';
Restart mysql service
Sometimes
bind-address = 127.0.0.1
should be
bind-address = *
MariaDB running on Raspbian - the file containing bind-address is hard to pinpoint. MariaDB have some not-very-helpful-info on the subject.
I used
# sudo grep -R bind-address /etc
to locate where the damn thing is.
I also had to set the privileges and hosts in the mysql like everyone above pointed out.
And also had some fun time opening the 3306 port for remote connections to my Raspberry Pi - finally used iptables-persistent.
All works great now.
I'm using AWS LightSail and for my instance to work, I had to change:
bind-address = 127.0.0.1
to
bind-address = <Private IP Assigned by Amazon>
Then I was able to connect remotely.
if you have many networks attached to you OS, yo must especify one of this network in the bind-addres from my.conf file.
an example:
[mysqld]
bind-address = 127.100.10.234
this ip is from a ethX configuration.
In my case the "bind-address" setting was the problem. Commenting this setting in my.cnf did not help, because in my case mysql set the default to 127.0.0.1 for some reason.
To verify what setting MySql is currently using, open the command line on your local box:
mysql -h localhost -u myname -pmypass mydb
Read out the current setting:
Show variables where variable_name like "bind%"
You should see 0.0.0.0 here if you want to allow access from all hosts. If this is not the case, edit your /etc/mysql/my.cnf and set bind-address under the [mysqld] section:
bind-address=0.0.0.0
Finally restart your MySql server to pick up the new setting:
sudo service mysql restart
Try again and check if the new setting has been picked up.
Update the bind-address = 0.0.0.0 in the /etc/mysql/mysql.conf.d/mysqld.cnf and from the mysql command line allow the root user to connect from any Ip.
Below was the only commands worked for mysql-8.0 as other were failing with error syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IDENTIFIED BY 'abcd'' at line 1
GRANT ALL PRIVILEGES ON *.* TO 'root'#'localhost';
UPDATE mysql.user SET host='%' WHERE user='root';
Restart the mysql client
sudo service mysql restart
mysql_update is what you need.
I don't know why anyone would follow the more complex ways of correcting this issue, when MySql graciously built a tool that already does this...
I've followed this tutorial to upgrade to mysql 5.5.
After finishing all the steps I do $ mysql -u root -pXXXX and it says:
Error 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES).
The tutorial worked for me sometime ago, but now I have this problem. I have reinstalled ubuntu+mysql 5.1 and I have no problem doing "mysql -u root -pXXXX", but after upgrading to 5.5 I get again the error above..
This is my /etc/my.cnf:
# The following options will be passed to all MySQL clients
[client]
#password = your_password
port = 3306
socket = /var/run/mysqld/mysqld.sock
# Here follows entries for some specific programs
# The MySQL server
[mysqld]
user = mysql
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
tmpdir = /tmp
log_error = /var/log/mysql/error.log
skip-external-locking
...
Any idea?
EDIT: solved, well.. I just should do a backup of the user 'root' since I'm removing the database before upgrading to 5.5.
Regards
Javi
It's just saying that you're using the wrong password really...
Maybe you have to reset the root password, though I wouldn't know why (maybe the updater overwrote it?), here's the procedure:
make sure there are no mysqld deamons running.
get to your mysql/bin directory
start a mysql deamon with mysqld_safe --skip-grant-tables (note the PID)
start command line mysql: mysql
execute this little script with your edit:
[code]
use mysql;
UPDATE user SET Password=PASSWORD('YOUR_NEW_PASSWORD_HERE') WHERE User = 'root';
exit;
[/code]
Now you're only need to kill your mysqld_safe (remember the PID?..) and start the deamon normally.
In Ubuntu 18.04, as root user:
# service mysql stop
# mkdir /etc/run/mysql && chown -R mysql:mysql /etc/run/mysql
# mysqld_safe --skip-grant-tables --user=mysql &
This will start mysql without validating root user. Then, in another terminal/ssh window, you can start mysql client and change the root user password:
# mysql -u root
mysql> FLUSH PRIVILEGES;
mysql> use mysql;
mysql> UPDATE user SET authentication_string = PASSWORD('NeWPaSSWoRD') WHERE User = 'root';
mysql> FLUSH PRIVILEGES;
mysql> exit;
Then, stop the mysqld_safe process in the first terminal. Replace the "processid" below with the contents of /var/run/mysqld/mysqld.pin.
# kill -9 "processid"
Start mysql and try logging in again.
# service mysql start
# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.26-0ubuntu0.18.04.1-log (Ubuntu)
mysql>
Save yourself of a MAJOR headache... Your problem might be that you are missing the quotes around the password. Specially because you can actually login passing the -p switch and not using your .my.cnf.
[client]
user = myusername
password = "mypassword"
host = localhost
http://dev.mysql.com/doc/refman/5.5/en/option-files.html
RE: CENTOS
Make sure you have set mysql to auto-start on boot:
chkconfig --list mysqld
If not, then add mysql to startup script:
chkconfig --levels 345 mysqld on
...and reboot.
If that still does not work, this did the trick for me:
/etc/init.d/mysqld stop
mysqld_safe --skip-grant-tables &
mysql -u root
mysql> use mysql;
mysql> update user set password=PASSWORD("newrootpassword") where User='root';
mysql> flush privileges;
mysql> quit
/etc/init.d/mysqld stop
/etc/init.d/mysqld start