I have just installed mySQL 5.1.55 on a Linux box, and it seems to be ok
# /usr/local/mysql/bin/mysql_install_db
Installing MySQL system tables...
160606 21:46:25 [Warning] '--skip-locking' is deprecated and will be removed in a future release. Please use '--skip-external-locking' instead.
OK
Filling help tables...
160606 21:46:26 [Warning] '--skip-locking' is deprecated and will be removed in a future release. Please use '--skip-external-locking' instead.
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/local/mysql-5.1.55/bin/mysqladmin -u root password 'new-password'
Alternatively you can run:
/usr/local/mysql-5.1.55/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd /usr/local/mysql-5.1.55 ; /usr/local/mysql-5.1.55/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd /usr/local/mysql-5.1.55/mysql-test ; perl mysql-test-run.pl
Please report any problems with the /usr/local/mysql-5.1.55/bin/mysqlbug script!
However, if I run
# /usr/local/mysql-5.1.55/bin/mysqladmin -u root password foo
I get this error message:
/usr/local/mysql-5.1.55/bin/mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'#'localhost' (using password: NO)'
If I run:
# /usr/local/mysql-5.1.55/bin/mysql -u root -p
I am not able to figure out which the password is :-S
Any help is welcome. Thank you very much.
If you have installed mysql without running
> mysql_secure_installation
script there should be no password at all. Just type
> mysql
and see what happens. If that fails you can still set a new root password following the mysql manual
Related
My knowledge in MySQL is very simple.
I installed MySQL 8.20 and as here to say, the Authentication Plugin was changed.
I tried as here to say,
logged in to MySQL:
mysql -u root -p
wrote:
CREATE USER 'sha2user'#'localhost'
IDENTIFIED WITH caching_sha2_password BY 'password';
In my file /etc/mysql/mysql.cnf I wrote:
default_authentication_plugin=caching_sha2_password
and restarted MySQL:
sudo systemctl restart mysq
Then on my Adminer I wrote user: root and Password: my new password, but got this warning:
The server requested authentication method unknown to the client
Can someone please help me?
so, found the solution...
My problem was how had installed ALL...
I removed ALL of Mysql on my Debian, I to search what i have of Mysql and MariaDB with dpkg -l | grep -e mysql -e mariadb, than with Synaptic delete ALL then..
Than Folge all as here to say.. Now have the last Adminer, 4.7.7 and all working gut..
I am trying to get MySQL running on my localhost. This never happened to me before, but upon installation sudo apt-get install mysql-server did not ask me for the initial password.
After searching for answers to "reset" my password and battling with directory permissions, i am currently at this state:
The mysqld_safe solution:
After rebooting my computer, mysql -u root -p will ask me for my password, and after i enter it, it will complain with ERROR 1698 (28000): Access denied for user 'root'#'localhost'
If i instead try mysql -u root (no password), it will say ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
If i run the advice that other people have posted about resetting the password via mysqld_safe --skip-grant-tables, then i run across some hiccups along the way:
First i run sudo service mysql stop
Then sudo mysql_safe --skip-grant-tables will say mysqld_safe Directory '/var/run/mysqld' for UNIX socket file don't exists.
I can fix that if i do sudo mkdir -p /var/run/mysqld and sudo chown mysql /var/run/mysqld
After this, running mysqld_safe will run with the message Starting mysqld daemon with databases from /var/lib/mysql and then hang. And Ctrl+C doesn't get me out of that.
In a new terminal window i can now actually connect with mysql -u root and get the mysql> prompt.
I can set a new password with use mysql; update user set authentication_string=password('0000') where user='root';flush privileges; which will tell me it successfully updated the row with the message Rows matched: 1 Changed: 1 Warnings: 1
The warning only states: 'PASSWORD' is deprecated and will be removed in a future release.
And after all this, i'm back at square one: The process still hangs, so i have to reboot because killall mysqld_safe says no process found. After rebooting and entering my new password 0000, i will get access denied.
The system is Linux 4.15.0-48-generic #51-Ubuntu SMP.
The mysqladmin solution
If i run mysqladmin -u root password '0000' (without sudo), i get:
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'#'localhost''
If i run it with sudo, i get:
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.
This last one doesn't really tell me anything in regards of whether the password change happened or not; has it been refused or not (since it's a warning, not an error, i would assume it should go through), but in either case, trying to connect with 0000 still says "access denied".
Any advice on how to fix this is greatly appreciated.
I didn't quite solve the problems with mysql directly; However for myself, the acceptable solution was switching to a different database software, but it's still a MySQL system, and it got me up and running. So if anyone gets stuck on existing solutions not working like i did, maybe this comes in handy to get you on the road and finally writing code again.
What i did was:
Purged mysql off my system
Manually deleted /etc/mysql and /var/lib/mysql (don't know if this step was necessary)
apt clean, apt autoremove, apt update
Installed mariadb
Followed these instructions to rid myself of the timeout bug
Used the mysqld_safe --skip-grant-tables method to create a new user with all privileges, since connecting with root always kept failing
PHP + MariaDB now working again.
I am following mysql on Cygwin.
# To begin MySQL setup run the following:
mysql_install_db
# Run mysql - you'll get a firewall alert from windows if you have it active.
mysqld_safe &
# Immediately following that, it would be wise to run the following:
mysql_secure_installation
During the mysql_install_db, I was asked who the database (DB) would be for. I specified a non-administrator account nonadmin.
For the mysql_secure_installation process, I followed the similarly named MariaDB page. In contrast to the description, I was told that I had no root password, so I set it to the same as my cygwin and windows administrator account.
I lost track of whether which account was used for each of the three commands above, but here is what I remember:
mysql_install_db: Ran as nonadmin, but prompted for admin password
mysqld_safe: Run as nonadmin
mysql_secure_installation: Attempted as nonadmin, abandoned, and
completed as administrator account admin
It seems that I should restart the server after the final step. Using ps -ef, I noted that process mysqld belongs to nonadmin. Using nonadmin, I attempted the mysqladmin shutdown command at mysql on Cygwin. I get:
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'nonadmin'#'localhost' (using password: NO)'
I tried the variation of the command that prompts the user for a password: mysqladmin -p shutdown. I did this twice, entering the cygwin/windows passwords for nonadmin and admin. Both times, I get:
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'nonadmin'#'localhost' (using password: YES)'
This totalled 3 attempts. I then switched to the admin account and retried all 3 attempts. I got the above messages, but with the username admin:
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'admin'#'localhost' (using password: NO)'
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'admin'#'localhost' (using password: YES)'
So no joy connecting to the daemon to shut it down. As an alternative, I want to avoid clobbering mysqld with kill -9 because I like things to terminate cleanly (though I will probably do so soon).
As another alternative, I've come across references to /etc/init.d, but I have no such file.
Can anyone please explain why I can't connect to the daemon to shut it down?
Also, I'm new to MySQL, so if possible, it'd be nice to find a way back to the process at mysql on Cygwin rather than deviating from it too much.
Thanks.
What I ended up doing was kill -9 on all mysql looking processes shown by ps -ef. I then deleted /var/lib/mysql -- and accidentally deleted all of /var/lib/*. Subsequently, therefore, I reinstalled all of my Cygwin packages, thus starting from a clean slate.
I also found the following more detailed process at this alaya page for installing a MySQL/MariaDB database on Cygwin, after which I was able to shut down the MySQL server.
from the Administrator terminal run:
mysql_install_db
Start the mysql server:
mysqld_safe &
then run:
mysql_secure_installation
You should then be able to log in to MariaDB from a non-administrative shell with:
mysql -u root -p
The initial mysql_install_db step generates the following useful looking information, which I'm capturing here because I'm not sure if there is a way to get it again.
Installing MariaDB/MySQL system tables in '/var/lib/mysql' ...
2019-05-01 23:00:06 0 [Warning] InnoDB: innodb_open_files 300 should not be greaterthan the open_files_limit 256
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !
To do so, start the server, then issue the following commands:
'/usr/bin/mysqladmin' -u root password 'new-password'
'/usr/bin/mysqladmin' -u root -h fmaPC password 'new-password'
Alternatively you can run:
'/usr/bin/mysql_secure_installation'
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the MariaDB Knowledgebase at http://mariadb.com/kb or the
MySQL manual for more instructions.
You can start the MariaDB daemon with:
cd '/usr' ; /usr/bin/mysqld_safe --datadir='/var/lib/mysql'
You can test the MariaDB daemon with mysql-test-run.pl
cd '/usr/mysql-test' ; perl mysql-test-run.pl
Please report any problems at http://mariadb.org/jira
The latest information about MariaDB is available at http://mariadb.org/.
You can find additional information about the MySQL part at:
http://dev.mysql.com
Consider joining MariaDB's strong and vibrant community:
https://mariadb.org/get-involved/
During the mysql_secure_installation step, I followed the recommendation to set a root password. Instead of the mysql -u root -p step, then, I could instead issue the following to stop the MySQL server:
mysqladmin -u root -p shutdown
I made an important discovery made about this process from the point of view of a user without administrator rights. Contrary to what is suggested on the alaya page cited above, the above process does not have to be done from an administrator account. Importantly, the user accounts with which one can connect to the MySQL server has nothing to do with the user accounts on the host system (Windows or *nix) (a fact that I got from perusing MariaDB knowledgebase). I suspect that any user on the host system can connect to any user account on the server via the socket that it presents [1], with the right password.
I also found that the above process works on a machine that has very restrictive Windows firewall policies. Even if the server (the mysqld_safe & step) and client (the mysql -u root -p step) are started from the same non-administrative account, the Windows firewall will issue a warning about curtailing some features. I suspect that the trigger is the creation of a socket for connecting to the server. Despite the warning, however, ps -ef shows the server to be running. Therefore, I suspect that the firewall restriction consists of allowing only loop-back connections. The mysql_secure_installation step apparently disallows external connections, and I found that after this step, stopping and relaunching the server no longer triggers the firewall warning. So the effect of mysql_secure_installation seems to persist into subsequent sqld launches, at least when they are started via mysqld_safe.
[1] "Present" might not be the right terminology here, as I'm more of an analyst rather than a developer or administrator.
I had some tweaking for my server and unfortunately I can't log to phpmyadmin via whm anymore nore via ssh as I have access denied for root#localhost.
I tried to change my sql root password via whm but it give me the following error :
Unable to reset the MySQL root password.
The subprocess reported error number 1 when it ended.
Can anyone help me?
You'll have to check if you are able to login to mysql from a command prompt. Login to your server via SSH and issue a mysql. It should login to your mysql server.
If that doesn't work then do a cat /root/.my.cnf. There you should have the previous mysql root password. Copy that password and try this:
mysql -u root -p (then when prompted paste the password if you have copied earlier).
If you get an authentication failed message then that password is not the correct one and you have to manually change (you said you can't change it from WHM).
Do you use a local mysql server or a remote mysql server?
In order to change the mysql root password you have to stop the mysql service on the server and start it manually with skip grants option.
Depending on your CentOS version you have to options to stop the mysql service:
- CentOS 6.x - /etc/init.d/mysql stop
- CentOS 7.x - systemctl stop mysql
Then manually start the mysql service:
mysqld_safe --skip-grant-tables
Then issue the following:
mysql --user=root mysql
update user set Password=PASSWORD('new-password') where user='root';
flush privileges;
exit;
Restart mysql and you should be able to login with your new password. You might also want to save it in /root/.my.cnf as well.
I hope it helps!
Bogdan, seems you have to issue one more command: use mysql;
And it's quite possible that issuing the command: update user set Password=PASSWORD('new-password') where user='root';
you will be errored that there is no field Password. It happens if you're running mysql server version 5.7+. In such case change command as follows:
use mysql;update user set authentication_string=PASSWORD('new-password') where user='root';
I've installed mysql5 using Macports and the installation appears to check out but I cannot login to the server at all.
This is what I did:
sudo port install mysql5-server
This builds and installs fine.
sudo /opt/local/lib/mysql5/bin/mysql_install_db --user=mysql
This runs fine as well. It outputs the following:
Installing MySQL system tables...
OK
Filling help tables...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/opt/local/lib/mysql5/bin/mysqladmin -u root password 'new-password'
/opt/local/lib/mysql5/bin/mysqladmin -u root -h LeoMacBook.local password 'new-password'
Alternatively you can run:
/opt/local/lib/mysql5/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd /opt/local ; /opt/local/lib/mysql5/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd /opt/local/mysql-test ; perl mysql-test-run.pl
Please report any problems with the /opt/local/lib/mysql5/bin/mysqlbug script!
Now...let's follow the instructions exactly. I start the server:
sudo /opt/local/lib/mysql5/bin/mysqld_safe &
Server is running fine.
When I try to change the root password, I CANNOT log in.
LeoMacBook:bin leonardteo$ /opt/local/lib/mysql5/bin/mysqladmin -u root password 'new-password'
/opt/local/lib/mysql5/bin/mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'#'localhost' (using password: NO)'
I'm at wits end.
I've started the server with --skip-grant-tables. With this, I can load up mysql fine from the command line and I'm connected to the server. When I run SELECT * FROM mysql.user;, it returns an empty set! With this, I've tried to create a new user by invoking the command:
CREATE USER 'root'#'localhost' IDENTIFIED BY 'root';
But this doesn't work. I get the error:
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
I cannot get this working. It seems I am so close, yet the root user seems to be missing.
Any ideas?
Leonard
Once you've started up mysql with --skip-grant-tables, issue a flush privileges; query. This'll re-enable the permissions system and allow you to run the usual grant and create user queries.