How to change directory in mysql command line tool? How to change directory in mysql command line tool? shell shell

How to change directory in mysql command line tool?


If you start the MySQL command line tool from the terminal, your working directory will be wherever you executed the binary from. For example in Windows, start the command prompt and then run the following:

cd "C:\my scripts path\"    "C:\Program Files (x86)\MySQL\MySQL Server 5.7\bin\mysql" -u root -p rootpassword

Now, you can execute source commands and just pass the script name rather than the entire absolute path. This is super useful for nesting scripts while using relative paths.

(I'm pretty certain this works in Linux too, but I only tested in Windows.)


The MySQL data directory can only be changed using the my.cnf (MySQL configuration) file. Changing that requires MySQL to be restarted.

If you want to import/load files to DB, the working directory will be the directory you were in when you started MySQL.

If you want to change directory after connecting to MySQL, use following command:

system cd /home/mfyounus


I think the solution you are looking for is to change the directory to access and run some script.

\system cd "C:\Users\Admin\Folder"