I have mysql installed on centos 7 on office, I expected it would have configuiration file located at /etc/mysql/my.cnf but I spotted directly under /etc.
is it possible to find out using the mysql cli the configuration file in use ?
Please refer here for details. The article discusses the default configuration file scan order.
But you could also specify the --defaults-file when starting mysql, please use ps -ef |grep mysql or similar command to check. On my machine, the output like this(suse12):
ps -ef |grep mysql
mysql 968 1 0 Apr27 ? 00:46:36 ./mysqld --defaults-file=/export/home/mysql/mysql-8.0.11/my.cnf --user=mysql
root 71136 65599 0 11:45 pts/0 00:00:00 grep --color=auto mysql
Related
I'm trying to set variable in /etc/mysql/conf.d/mysql.cnf file:
[mysqld]
innodb_flush_log_at_trx_commit=0
But after restarting mysql server via command "/etc/init.d/mysql restart"
variable isn't changed (the value is still 1).
Any advises?
To be sure which file MYSQL is reading do
mysqld --verbose --help
the first line of the output will tell you where MYSQL will look for its .cnf or .ini file
Use this command to know the conf file mysql is using..
mysql --help | grep Default -A 1
I am able to connect to mysql database and query it. But, I am NOT able to find the socket file.
$ps -ef|grep mysql
mysql 31408 30874 0 18:46 pts/1 00:00:00 /bin/sh /usr/bin/mysqld_safe --defaults-file=/mysql/admin/ofile/TEST1.cnf
mysql 31959 31408 0 18:46 pts/1 00:00:01 /usr/sbin/mysqld --defaults- file=/mysql/admin/ofile/TEST1.cnf --basedir=/usr -- datadir=/mysql01data/TEST1/data --plugin-dir=/usr/lib64/mysql/plugin --log- error=/mysql/admin/TEST1/errors/mysqld_safe.err --pid- file=/mysql/admin/TEST1/run/mysqld_safe.pid
Here is my socket file entry in TEST1.cnf:
$ cat /mysql/admin/ofile/TEST1.cnf|grep sock
socket = /mysql/admin/TEST1/run/TEST1.sock
The corresponding directory only contains pid file. There is no socket file.
-sh-4.1$ cd /mysql/admin/TEST1/run
-sh-4.1$ ls -lrt
total 4
-rw-rw---- 1 mysql mysql 6 Apr 29 18:46 mysqld_safe.pid
This is the MySQL 5.6 version I installed through RPM's on RHEL 6.5. I have my old custom scripts which uses socket file to connect to the database.
So, I am wondering how I can use the socket file to connect to the database? Why the socket file is not created by default?
The socket file for a running instance of MySQL Server should be something that can be found with this shell command:
sudo lsof -a -U -p $(pgrep -d, -f /path/to/your/running/mysqld)
One possible cause of being unable to find the socket file would be if it had been deleted after the server was started. In that case the above command should work, and show something like (deleted) after the path.
That was my original assumption on this question... but here the issue was a configuration oversight. The "defaults file," commonly called my.cnf contains multiple sections. The [client] section configures client utilities, like mysql and mysqldump, while the [mysqld] section configures the server daemon. If the socket directive isn't in the appropriate section, the server (and/or client utilities) will look in the location compiled in by default, with /tmp/mysql.sock or /var/lib/mysql/mysql.sock being a couple of examples of common default locations.
I need to check if mysql is installed on a ubuntu server. Is there a way to determine if mySql has been installed ? Thanks.
You can use tool dpkg for managing packages in Debian operating system.
Example
dpkg --get-selections | grep mysql if it's listed as installed, you got it. Else you need to get it.
"mysql" may be found even if mysql and mariadb is uninstalled, but not "mysqld".
Faster than rpm -qa | grep mysqld is:
which mysqld
Multiple ways of searching for the program.
Type mysql in your terminal, see the result.
Search the /usr/bin, /bin directories for the binary.
Type apt-cache show mysql to see if it is installed
locate mysql
With this command:
dpkg -s mysql-server | grep Status
# mysqladmin -u root -p status
Output:
Enter password:
Uptime: 4 Threads: 1 Questions: 62 Slow queries: 0 Opens: 51 Flush tables: 1 Open tables: 45 Queries per second avg: 15.500
It means MySQL serer is running
If server is not running then it will dump error as follows
# mysqladmin -u root -p status
Output :
mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)'
Check that mysqld is running and that the socket: '/var/run/mysqld/mysqld.sock' exists!
So Under Debian Linux you can type following command
# /etc/init.d/mysql status
In an RPM-based Linux, you can check presence of MySQL like this:
rpm -qa | grep mysql
For debian or other dpkg-based systems, check like this:
*
dpkg -l mysql-server libmysqlclientdev*
*
Lots of answers. It should have been a simple command. Just type mysql --version on your terminal and hit enter.
Try executing 'mysql' or 'mysql -- version' without quotes on terminal.
it will prompt version otherwise Command Not Found
When I run apt-get install percona-server-server-5.6, the percona server gets installed and started. The processes running (ps -ef | grep mysql) look like this (HOSTNAME is obfuscated):
root 14309 1 0 23:54 ? 00:00:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --pid-file=/var/lib/mysql/HOSTNAME.pid
mysql 14413 14309 3 23:54 ? 00:00:00 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --user=mysql --log-error=/var/lib/mysql/HOSTNAME.err --pid-file=/var/lib/mysql/HOSTNAME.pid
My question is where is this default PID file coming from? There is no my.cnf file under /etc/mysql and the my.cnf file under /usr doesn't have any of this information. This is causing a problem ebcause when I deploy my configuration file and try to restart the server, the box obviously doesn't work. I believe the correct default for the PID file is /var/run/mysqld/mysqld.pid.
Looks like this is being set in the init mysql file.
I have installed zend server on my iMac. I can log on to zend server and i can log in to phpmyadmin, using user: root pw: (blank)
However. I am desperately trying to open mysql using the terminal. I have tried for 3h now and wiht all kinds of pathways and sudo-whatnot..
This i get when:
Williams-iMac:mysql uglyface$ cd /usr/local/zend/mysql/bin
Williams-iMac:bin uglyface$ ls
innochecksum mysql_config mysqlaccess.conf mysqlhotcopy
msql2mysql mysql_convert_table_format mysqladmin mysqlimport
my_print_defaults mysql_find_rows mysqladmin.client mysqlmanager
myisam_ftdump mysql_fix_extensions mysqlbinlog mysqlshow
myisamchk mysql_fix_privilege_tables mysqlbug mysqlslap
myisamlog mysql_secure_installation mysqlcheck mysqltest
myisampack mysql_setpermission mysqld mysqltest_embedded
mysql mysql_tzinfo_to_sql mysqld-debug perror
mysql.client mysql_upgrade mysqld_multi replace
mysql.server mysql_waitpid mysqld_safe resolve_stack_dump
mysql_client_test mysql_zap mysqldump resolveip
mysql_client_test_embedded mysqlaccess mysqldumpslow setup_mysql.sh
So in here i can se mysql, but i haven been able to do anything with it. I am sorry for way of displaying the output i get. I tried to get it to display differently but with no success as you can see...
Do any one know what i can do, so that i can log in to my mysql?
/W
edit: There is no mysql located in /usr/local/bin...
If mysql is running (you start it with the zend server controller), you should be able to do:
/usr/local/zend/mysql/bin/mysql -uroot -p <your dbname>
You can verify mysqld is running by a simple
ps -ef | grep mysqld
If it's running, you'll see more than just your grep command in the resulting process list.