Cannot find MySQL when trying to load a database - mysql

I'm trying to load a database into MySQL. I'm on a Mac, and I can see the MySQL server running in the system preferences. Also, when I issue the shell command mysql I'm entered into the interactive mode of mysql. However, when I try to load a database from the shell:
mysql -f --user root --password mypassword < database.sql
it gives me back zsh: command not found: mysql. Putting sudo in front does not make a difference. How can this be?

Related

MySQL Shell always gives error no matter what I type

I have even switched to the \sql mode.
I have tried \connect root#localhost;
I have tried with mysql --host=localhost --port=3306 --user=root -p;
I am new to this . I installed the entire .msi package too.
If i run the MySql Command Line Client, everything works.
This brings me to another doubt. What is the purpose of MySQl shell?

How to connect to MYSQL database on server via Terminal on Macbook?

Is there a way to connect to my mysql database and do sth on tables via terminal?
Yes. In your terminal start the mysql prompt using
mysql --user=user_name --password=your_password db_name
Where db_name is the name of your database and user_name and password are your username and password.
You can then run SQL statements/queries from .sql files
mysql db_name < script.sql > output.tab
Where db_name is your database name, script.sql is a file containing your script, and output.tab (optional) is a file in which to dump the output of the query
You then simply place an SQL query in a file and run it.
If you get the error mysql: command not found, this is because the mysql executable cannot be found in your system PATH. If so, you need to run the following command to add the mySQL folder to the PATH, so that OS X knows to look there for the executable
export PATH=${PATH}:/usr/local/mysql/bin
Where /usr/local/mysql is the location of your mysql installation.
You can add this to your .bash_profile file (located at ~\.bash_profile, or you can create it) in order to have it run every time you start a new terminal. Otherwise you'll have to enter it manually before using the mysql command
Once you've entered this command (or added it to .bash_profile) you can use the mysql command as above
Alternately navigate to /usr/local/mysql/bin (or the location of your mysql install) and use the command
./mysql command
Instead of
mysql command
As above (where command is the command described in the first half of this post). This runs the mysql binary directly, rather than searching for it in the PATH

Backup DB from MYSQL command prompt

I recently tried to put my web application and mysql database on the same virtual server. Now I receive a port error. In order to fix the port issue, I want to back up the database and reinstall WAMP. Since I can't get to the phymyadmin, I have to use the mysql command prompt to do a dump.
Would anyone happen to know the EXACT command to put in, if my username is root, I have no password, and the database name is dev? I've tried it multiple ways and I get an error saying that my syntax is wrong.
Thanks in advance.
You can use the following command provided you know the name of the database:
mysqldump -u root -p[root_password] [database_name] > dumpfilename.sql
Alternatively I would install the MySQL Workbench which can connect to your local database instance and provides a GUI to run the export: MySQL Workbench.
Unfortunately if you've uninstalled WAMP then MySQL might not be running anymore, and the above commands will not work because the utilities cannot see the database. If this is the case, try installing WAMP to a new directory and manually copying over the MySQL data files:
How to restore MySQL database from WAMP?
mysqldump -u root -p dev > devBackUp.sql
DOS batch file to export the database with date and time in the filename
FOR /f "tokens=1-8 delims=:./ " %%G IN ("%date%_%time%") DO (
SET dt=%%G%%H%%I_%%J_%%K
)
mysqldump -u root -p[root_password] [database_name]> [database_name]_%dt%.sql
pause

mysql command line client for linux

I just installed mysql 5.6 in a new CentOS 7 linux installation. I want to use the mysql command line client that I have been used to using in windows, but I cannot seem to find it. Is there a mysql command line client for linux? If so, how do I make sure that I have it? And how do I open it up in the GUI?
You can open MySql command line utility using following command
mysql -u user_name -p
It will ask for password for user_name. If password is not set call as follows
mysql -u user_name
First make sure the service is running :
sudo systemctl start mysqld
Then make sure to run the security script that will remove some dangerous defaults and lock down access to our database system a little bit.
sudo mysql_secure_installation
Now you can use the command line tool
mysql --user=user_name --password=your_password db_name

how to run mysql v5.5 on redhat linux

I am new to both linux and also mysql but somehow by obtaining help from net I have installed mysql v5.5 on redhat. It starts fine, I have confirmed this by running command:
"/etc/init.d/mysqld status"
But I am not able to change password using command:
mysqladmin -u root password 'new-password'
It gives error : bash: mysqladmin: command not found.
I tried searching mysqladmin by using command "find / -name mysqladmin" but it returned no result
All I can search on net is adding to path '/bin:/usr/local/mysql/bin' but directory structure after installation mysql v5.5 has changed. There is no such directory like /usr/bin/local/mysql now.
please help me with how to run mysql after changing root's password.
first of all see what MySQL packages are installed
rpm -qa | grep -i mysql
Second, try using locate in order to find the tool path
BTW,
According to pbone mysqladmin is provided by mysql-client (rather than mysql) as it was on older cackeages