Im trying to login to MySQL in localhost using the root username (default) with no password entering the following command:
mysql -u root -h localhost
I dont get the 'mysql>' and it does not fail so im left with the terminal letting me type but it does not execute any commands (inside or outside of mysql). I also tried using -p and leaving the password blank and I get the same result
Check the following (taken from http://dev.mysql.com/doc/mysql-linuxunix-excerpt/5.5/en/unix-postinstallation.html )
Use mysqladmin to verify that the server is running. The following commands provide simple tests to check whether the server is up and responding to connections:
shell> bin/mysqladmin version
shell> bin/mysqladmin variables
The output from mysqladmin version varies slightly depending on your platform and version of MySQL, but should be similar to that shown here:
shell> bin/mysqladmin version
mysqladmin Ver 14.12 Distrib 5.5.29, for pc-linux-gnu on i686
...
Server version 5.5.29
Protocol version 10
Connection Localhost via UNIX socket
UNIX socket /var/lib/mysql/mysql.sock
Uptime: 14 days 5 hours 5 min 21 sec
Threads: 1 Questions: 366 Slow queries: 0
Opens: 0 Flush tables: 1 Open tables: 19
Queries per second avg: 0.000
If you are unable to run that command then your installation is either not complete (follow the instructions starting at the top of the page ) or you do not have permission as the user to execute the mysql program.
Related
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
I'm trying to explore MySQL 8 datastore. After opening MySQL shell and connecting to the sample database provided by MySQL here, world_x, when I run the query to list collections, I get the following error:
zsh: killed mysqlsh --mysqlx -u root -h localhost -P 33060
When I type db., intellisense is listing all the available collections and datastore functions as seen in the screenshot.
How can I proceed here?
I have installed some production, there is mysql embedded instance in production. Installation is successful, but when I tried to connect mysql instannce, I got following error messages.
[root#MiWiFi-R3D-srv bin]# ./mysql -u root
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/msql.sock' (2)
[root#MiWiFi-R3D-srv bin]#
[root#MiWiFi-R3D-srv bin]#
I can sure mysql instance is running.
aam 13390 1 0 08:01 ? 00:00:00 /bin/sh /opt/SIU_MANAGER/mysq /bin/mysqld_safe --defaults-file=/var/opt/SIU_MANAGER/mysql/my.cnf --pid-file=/var/opt/AAM/mysql/data/my.pid --ledir=/opt/AAM/mysql/bin --basedir=/opt/AAM/mysql --tmpdir=/var/opt/AAM/mysql/tmp/ --datadir=/var/opt/AAM/mysql/data --character-sets-dir=/opt/AAM/mysql/share/charsets/ --lc-messages-dir=/opt/AAM/mysql/share --lc-messages=en_US --user=bin
aam 13578 13390 0 08:01 ? 00:00:02 /opt/AAM/mysql/bin/mysqld --defaults-file=/var/opt/AAM/mysql/my.cnf --basedir=/opt/AAM/mysql --datadir=/var/opt/AAM/mysql/data --plugin-dir=/opt/AAM/mysql/lib/plugin --tmpdir=/var/opt/AAM/mysql/tmp/ --character-sets-dir=/opt/AAM/mysql/share/charsets/ --lc-messages-dir=/opt/AAM/mysql/share --lc-messages=en_US --log-error=MiWiFi-R3D-srv.err --pid-file=/var/opt/AAM/mysql/data/my.pid
root 17786 11762 0 08:27 pts/1 00:00:00 grep --color=auto mysql
I did little research. Mysql offical solution is that execute sql in mysql, but if I can not connect sql
I can not execute any sql.
Mysql offical solution https://dev.mysql.com/doc/mysql-security-excerpt/5.7/en/account-locking.html
When used with ALTER USER, these clauses specify the new locking state
for an existing account. In the absence of either clause, the account
locking state remains unchanged.
This is mysql version.
[root#MiWiFi-R3D-srv bin]# ./mysqladmin -V
./mysqladmin Ver 8.42 Distrib 5.7.25, for linux-glibc2.12 on x86_64
[root#MiWiFi-R3D-srv bin]#
How do I unlcok root user?
PS: I have root privillage of OS.
Thank you for answer me.
It looks like, for some reason, your communication socket for MySQL is being created in /tmp, and is presumably being deleted by some process that periodically cleans up /tmp.
You can get it back by restarting the mysqld process through whatever means is appropriate to your system.
You should also move it out of /tmp, perhaps into /var/run.
I’m trying to import a 4GB+ SQL to MySQL 5.6 (64-bit) on Windows 7 (64-bit)
The problem is I after a few seconds (), get this message:
ERROR 2006 (HY000) at line 204: MySQL server has gone away
It does import, but it only the first 3 tables (the first 2 and the 3rd table just the structure.
I’ve been trying this command:
mysql -u root -p firedb < C:\database_2013-11-12.sql
I tried a lot of things I could find here on stackoverflow with no success yet:
[mysqld]
innodb_file_per_table
max_allowed_packet=2048M
wait_timeout=3600
net_read_timeout=3600
net_buffer_length=3600
The SQL file was created on “MySQL 5.1.72-2-log (Debian)” using this command:
mysqldump -u root -p --all-databases
I have also tried setting --max_allowed_packet when running the command like this:
mysql --max_allowed_packet=2048M -u root -p --all-databases
The Documentation states:
The most common reason for the MySQL server has gone away error is
that the server timed out and closed the connection.
By default, the server closes the connection after eight hours if
nothing has happened. You can change the time limit by setting the
wait_timeout variable when you start mysqld. See Section 5.1.4,
“Server System Variables”.
If you have a script, you just have to issue the query again for the
client to do an automatic reconnection. This assumes that you have
automatic reconnection in the client enabled (which is the default for
the mysql command-line client).
So i would start with increasing the timeout.
And if this does not help read int he attached documentation link for the rest of reasons for server has gone away error.
I am trying to connect to SphinxQL server through Linux command-line this way:
> mysql -P 9306
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: NO)
My Sphinx config file has 2 listen entries:
listen = 9312
listen = 9306:mysql41
searchd daemon is running:
> ps ax | grep searchd
10727 ? S 0:00 /usr/local/sphinx/bin/searchd
10728 ? Sl 0:00 /usr/local/sphinx/bin/searchd
Regular search queries work perfectly:
> /usr/local/sphinx/bin/search StackOverflow | more
Sphinx 2.0.4-release (r3135)
Copyright (c) 2001-2012, Andrew Aksyonoff
Copyright (c) 2008-2012, Sphinx Technologies Inc (http://sphinxsearch.com)
using config file '/usr/local/sphinx/etc/sphinx.conf'...
index 'test1': query 'StackOverflow ': returned 2 matches of 2 total in 0.009 sec
displaying matches:
1. document=1788212, weight=1797
id=1788212
...
So, what I am doing wrong? How can I get access to SphinxQL console?
Any hint will be appreciated. Thanks in advance!
the 'mysql' client, will totally ignore the -P param, if it detects mysql is running on a unix-socket. So really even though you ask for the sphinxQL port, you are connecting to mysql
Use
mysql -P9306 --protocol=tcp
to tell the client to ignore the socket.
Pro Tip:
mysql -P9306 --protocol=tcp --prompt='sphinxQL> '
which serves as a useful ongoing reminder you are connected to sphinx not mysql :)
Works for me:
mysql -P 9306 -h 0
I ran into this recently. I was able to get in to Sphinx via the mysql shell by commenting out the listen configuration that didn't specify MySQL. This may not work for you, if you still need to get to searchd via the API.