MYSQL root password reset error - mysql

Running a server on Ubuntu, and needed to reset the mysql root password. Here is what I usually do (which usually seems to work):
Stopping the mysql server:
/etc/init.d/mysql stop
Starting the mysql server without password:
mysqld_safe --skip-grant-tables &
The error after running the command above:
[1] 14459
forge#test:~/dev.test.com$ 150809 15:12:01 mysqld_safe Can't log to error log and syslog at the same time. Remove all --log-error configuration options for --syslog to take effect.
150809 15:12:01 mysqld_safe Logging to '/var/log/mysql/error.log'.
150809 15:12:01 mysqld_safe A mysqld process already exists
Any ideas? I have never seen this before.
EDIT: It may be worth mentioning I am using Forge for deployment.

You have to add the --skip-syslog option to the startup command, more details here:
Mysqld-safe

The problem was that Forge seems to re-start mysql by default if you turn it off in the command line...
By going into Forge, I was able to turn it off using the user-interface (Stop Services) for the particular server.

Related

fail to start mysql(mariadb)

i have been spending hours figuring out problems in connection mysql to use mariadb eventually. here's a situation.
situation:
1.i use macbook, and i am not that familiar with computer programming.
i tried to connect java eclipse and mariadb. so i looked it up online.
and at the same time, i opened up terminal and started my mysql using
mysql.server start
and it worked. and i was supposed to download mariaddb.2.2 jar something to connect it with eclipse, but i mistakenly downloaded "mariadb-10.2.12-osx10.13-x86_64.pkg" and installed it. and i also typed
mysql.server stop
and all that kind of things. lots and lots of things so that i can`t even remember
after i found out i downloaded the wrong things, i felt like this is way beyond my skills, so i jumped back to play with mariadb.
i opened up terminal and typed
mysql.server start
and termial keeps showing me this until now
.180322 00:04:47 mysqld_safe Logging to '/usr/local/var/mysql/sinjinhos-MacBook-Air-146.local.err'.
180322 00:04:47 mysqld_safe Starting mysqld daemon with databases from /usr/local/var/mysql
. ERROR!
i still think that this tragedy started beacause i installed mariadb again...
i literally tried everything and still couldn`t figure it out.
please help me!!
From your initial post you can see that mariadb is logging the following file.
180322 00:04:47 mysqld_safe Logging to '/usr/local/var/mysql/sinjinhos-MacBook-Air-146.local.err'
Inside that file you found the following error.
2018-03-22 0:36:36 140736284734272 [ERROR] Can't start server: Bind on TCP/IP port. Got error: 48: Address already in use 2018-03-22 0:36:36 140736284734272 [ERROR] Do you already have another mysqld server running on port: 3306 ? 2018-03-22 0:36:36 140736284734272 [ERROR] Aborting
The key part of the error is Address already in use. Everything running on your computer that listens for connections (like a database or a web server) will listen on a specific port. MySQL (and therefore MariaDB) listens on port 3306 by default. The important part is that you can't have multiple applications listening on the same port!
So where do you go from here? I suspect you still have MySQL running on your laptop, and once you stop it you will be able to start up a new instance.
To check if MySQL is running you can use the following command:
ps -ef | grep mysql
If anything shows here then it is running, and you should stop the service. How you do this will vary depending on how you installed it - try mysql.server stop first and run the above command again. If it is still running and you can't figure it out then you can kill the service. This is not recommended and cause MySQL data corruption - although if you have no data there then you should be OK.
Example output of ps -ef. Yours should show MySQL near the end, and the second column shows the process ID which you can use to kill the process.
PID
\/
0 9504 9491 0 3:44pm ttys007 0:00.00 ps -ef`
So I would use:
kill 9504
You should then be able to start the service again.
mysql.server start

MacOS Can't start MySQL Server

I have MacOS Sierra. I have installed MySQL Server which has been working, however, after a reboot of the Mac Book, I cannot start the MySQL Server.
I have tried changing the port from 3306 to 3307 in the my.cnf file.
Question
I would appreciate any help on how to start the MySQL Server, and also have it so it starts automatically on MacOS Boot up.
(I am new to Mac, so apologies if this is a basic question).
UPDATE
Looking for error logs, I can't find anything with todays (2/2/2017) timestamp.
Nothing in the data dir:
No files with "mysql" have been modified since I've tried to start the MySQL Server (2/2/2017 after 09:00).
I suggest using Terminal commands.
Start MySQL
sudo /usr/local/mysql/support-files/mysql.server start
Stop MySQL
sudo /usr/local/mysql/support-files/mysql.server stop
Restart MySQL
sudo /usr/local/mysql/support-files/mysql.server restart
In my case, I had inadvertently transferred ownership of entire /usr/local directory to myself, which resulted in snatching-away of write permission of /usr/local/mysql-5.7.20-macos10.12-x86_64/data directory from the daemon user called "_mysql".
Restoring the ownership fixed the issue.
After a discussion with Richard, the following solves the issue:
my.cnf:
[client]
port = 3306
socket = /tmp/mysql.sock
[mysqld]
port = 3306
socket = /tmp/mysql.sock
datadir = /usr/local/mysql-5.7.17-macos10.12-x86_64/data
tmpdir = /tmp
Essentially, although we'd added the relevant stanza's to the my.cnf file, we'd still missed the section heading. Adding the [mysqld] section allowed mysql to start.
After installing Mysql 8.0.12 on MacOS High Sierra, Mysql server would not start up. I tried several suggestions like removing mysql and reinstalling it, rebooting the computer and changing file permissions, all to no avail. I finally got it to work by removing /etc/my.cnf.
In my case, ownership of the msyql directory had somehow changed to admin:admin. I use ares suggestion to run mysqld from the terminal:
sudo /usr/local/mysql/support-files/mysql.server start
Which showed a permissions error writing to a msyql file.
I fixed with this command:
sudo chown -R _mysql:wheel /usr/local/mysql/data
from this post:
What user should own /usr/local/mysql on Mac?
In my case, First time, after installing Mysql, Mac needs a restart.
So restarting Mac, after installation, fixed the issue for me.
MacOS doesn't come with a my.cnf file. Default settings will suffice the needs for basic usage. Once we need to override them, it makes sense to have a custom configurations.
This solution works for me.
You have to open the activity monitor up and search for mysqld service. Once selected, just click the delete button located in the up left part and you will see the memory goes down. After that, you can verify your mysql server status from System Preferences and the service is up.
With this solution you don't have to restart your machine and get to work fast.
My problem was that due to an incorrect restart of my machine, a database was corrupted. According to their docs doing a forced InnoDB Recovery did the trick:
/etc/my.cnf
innodb_force_recovery = 2
My problem was that I installed MySQL a while ago with Homebrew (forgot I did) and then went the more manual route, so I think the two installs were fighting each other. I wiped my Mac of both with the help of this walkthrough: https://gist.github.com/vitorbritto/0555879fe4414d18569d
Note: Where it says to use subl - that's Sublime, use whatever editor you like.
I was able to get things to work with a fresh install after that.
I had this same issue on Monterey. Make sure you're selecting the correct download according to your processor architecture.
I ran into same problem with following .err log.
MacOS: Catalina 10.15.7.
MySQL version: 5.7.19.
2021-08-19T02:17:26.6NZ mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
2021-08-19T02:17:27.303813Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2021-08-19T02:17:27.318280Z 0 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
2021-08-19T02:17:27.335112Z 0 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.7.19) starting as process 2828 ...
2021-08-19T02:17:27.421394Z 0 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/mysql/data/ is case insensitive
2021-08-19T02:17:27.428986Z 0 [ERROR] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root!
2021-08-19T02:17:27.429541Z 0 [ERROR] Aborting
2021-08-19T02:17:27.429688Z 0 [Note] Binlog end
2021-08-19T02:17:27.432786Z 0 [Note] /usr/local/mysql/bin/mysqld: Shutdown complete
And I found adding --user=root to Ares's answer will start mysql server successfully.
sudo /usr/local/mysql/support-files/mysql.server start --user=root
Ref.: MySQL Server Command User Options

How do you start a MySQL server on linux?

Pretty simple question here. I just want a SQL database on my version of Kali linux so I can practice SQL.
I opened the command line and entered tried to start mysql and get an error.
> mysql -u root
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'
I also made sure it was already installed using apt-get.
What are the steps I need to take to be able to make a database with tables and data that I can query?
I don't know about Kali, but on Ubuntu it would be
$ sudo service mysql start
Once that command returns, the mysqld service has started, so you can use the mysql client to connect to it.
Of course, you also have to make sure you have the mysql-server package installed, not just mysql-client and mysql-common, and that you've initialized the database instance. Complete post-installation instructions can be found in the official documentation, but the short version is
Make sure the installer has created the mysql user account. This is the account that will "own" the server process once it starts.
Change to your data directory. (I used the installer's default of /var/lib/mysql; you can change this by editing my.cnf.)
As root, execute the server daemon with the --initialize switch. Check whereis to determine the correct path, then
$ sudo /path/to/mysqld --initialize --user=mysql
This command will twiddle itself for a while, then display an automatically-generated password and exit. Once the command returns, the database instance has been initialized and the system tables created. You can now start the database instance normally (using service start), then log in as the database user root (which is not the same as the system user root) using the password from above, then change your password, create a new database user, log in as that user, create a user database, and start creating tables.
Again, the official documentation is the place to look for this; if any of the instructions in the official documentation differ from my instructions, you should ignore me and follow the official documentation's instructions.
If sudo service mysql start doesn't work for you, please try running mysqld_safe and don't kill the process. Use another tab to check the status of mysql service. This should solve your mysqld.sock issue.
If it doesn't work out, then please edit your my.cnf file and add the following:
socket=/var/lib/mysql/mysql.sock
And the permissions,
sudo chmod -R 755 /var/lib/mysql/
Hopefully, this should do it.
On my version of kali (2022-rolling), even though it's installed as MySQL, it's run as mariadb. To start it is:
sudo /etc/init.d/mariadb start
Try this
sudo service mysql start

mysql wont start on Oracle Linux

I installed mysql following instructions on this link on my fresh installation of OEL 5. However when I try to start the mysql service with service mysqld start I keep getting
chown: `mysql:mysql': invalid user
chown: `mysql:mysql': invalid user
MySQL Daemon failed to start.
Starting mysqld: [FAILED]
When I try to check user's information with id mysql I get user does not exist and when I try to add user, it says user already exists!
If I try to start mysql or ecen check its version for instance, I get:
[root#localhost ~]# mysql -v
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
Worst part is there is no mysql.sock file on my whole file system. I confirmed it by firing find / -name mysql.sock which returned empty result.
AM I missing some configuration step or something? I am absolutely clueless. Can someone please help me with this?
Please, which of the corresponding linux distribution are you using ? have you try to run it in sudo mode: sudo service mysqld start ? To see if mysql user have been created run cat /etc/passwd | grep 'mysql' or cat /etc/passwd; normally; it special user for specific purpose (here mysql administration).

How to disable --skip-grant-tables in MySQL?

I am trying to initialize the database for my OpenGTS installation. However, when I run the shell script that accomplishes this, I get the following error:
Version: 2.4.5
Database created: gts
[ERROR|DBAdmin.execCommands:843] ==> SQLException: DB grant error [jdbc:mysql://localhost:3306/]
[ERROR|DBAdmin.execCommands:843] Message: The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
[ERROR|DBAdmin.execCommands:843] SQLState: HY000
[ERROR|DBAdmin.execCommands:843] ErrorCode: 1290
[DBAdmin.execCommands:843] java.sql.SQLException: The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
java.sql.SQLException: The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1055)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3558)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3490)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1959)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2109)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2642)
at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1647)
at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1566)
at org.opengts.dbtools.DBConnection._executeUpdate(DBConnection.java:961)
at org.opengts.dbtools.DBConnection.executeUpdate(DBConnection.java:908)
at org.opengts.dbtools.DBConnection.executeUpdate(DBConnection.java:889)
at org.opengts.dbtools.DBProvider.grantDBUser(DBProvider.java:2132)
at org.opengts.dbtools.DBAdmin.execCommands(DBAdmin.java:841)
at org.opengts.db.DBConfig._main(DBConfig.java:1246)
at org.opengts.db.DBConfig.main(DBConfig.java:1361)
I think it's pretty clear that I need to disable --skip-grant-tables, but I am new to MySQL and SQL in general. Recently, I followed a tutorial to reset the MySQL root password and I believe I enabled --skip-grant-tables through that. I've tried looking for solutions to disable this, but haven't come across anything.
Anyone able to help?
Just type: mysqladmin shutdown and then start MySQL service by running command: service mysql start.
:-)
Check your my.cnf file, you probably added that option in there.
Try this:
sudo systemctl set-environment MYSQLD_OPTS=""
(It worked for me.)
you must have stopped the server and run this
mysqld_safe --skip-grant-tables due to root pwd chg
so stop the server and start it normal with a start