This post isn't duplicate. I already referred this post and this post but the answers doesn't help
I am trying to execute a code in mySQL client window. HowEVER,I get the below error
The used command is not allowed with this MySQL version
What I did
SET GLOBAL local_infile = 1;
SHOW VARIABLES LIKE 'local_infile';
I executed the above commands in MySQL 8.0 Command Line Client
When I tried to do the same thing in MySQL Shell, I get the below error as Unexpected identifier
I am assuming MySQL Shell is the server. Do we have to do this at both client and server side?
How do I resolve this? In addition, whenever I launch command line client, I am only prompted to type password. So I am not able to pass it as a parameter. my clinet looks like as shown below
But how do I pass the below parameters while logging in then?
mysql -u abcd -p password_here --local-infile=1
I am new to MySQL and can you guide me?
Q1:
To run sql commands in MySQL Shell you need to change from default JS to sql
R1:
type \sql to change from js to sql
mysql-js> \sql
Q2:
so I am not able to pass it as a parameter
For this you must be selecting 'MySQL x.x Command Line Client' under windows search.
To resolve you need to have mysql bin folder in environment path or do the below step to access
R2:
Goto "C:\Program Files\MySQL\MySQL Server x.x\bin" this is windows default path unless you change.
Then in the address bar if you click it will select ( i.e. C:\Program Files\MySQL\MySQL Server 5.7\bin) there just type cmd (Note: now in the address bar you will see only cmd) then press enter.
Once cmd window opens with the mysql path like below
C:\Program Files\MySQL\MySQL Server 5.7\bin>
Type blah..blah.. blah
mysql -u abcd -p password_here --local-infile=1
Note: If you just parse -p instead of -ppassword it will ask for password after that. So if you are going to type the password directly then type -pyourpass there will not be any spaces between -p and password
Related
I'm having a serious troublesome situation trying to reset my MySQL's root password. I'm following the dev.mysql.com instructions:
Step 1. Log on to your system as Administrator.
Step 2. Stop the MySQL server if it is running. For a server that is running as a Windows service, go to the Services manager: From the Start menu, select Control Panel, then Administrative Tools, then Services. Find the MySQL service in the list and stop it.
If your server is not running as a service, you may need to use the Task Manager to force it to stop.
Step 3. Create a text file containing the password-assignment statement on a single line. Replace the password with the password that you want to use.
MySQL 5.7.6 and later:
ALTER USER 'root'#'localhost' IDENTIFIED BY 'MyNewPass';
MySQL 5.7.5 and earlier:
SET PASSWORD FOR 'root'#'localhost' = PASSWORD('MyNewPass');
Step 4. Save the file. This example assumes that you name the file C:\mysql-init.txt.
Step 5. Open a console window to get to the command prompt: From the Start menu, select Run, then enter cmd as the command to be run.
Step 6. Start the MySQL server with the special --init-file option (notice that the backslash in the option value is doubled):
C:\> cd "C:\Program Files\MySQL\MySQL Server 5.7\bin"
C:\> mysqld --init-file=C:\\mysql-init.txt***
That's where I'm stuck: step 6. I did everything accordingly, and cmd gives me back:
mysqld: CAN'T CHANGE DIR TO 'C:Program Files\MySQL\MySQL SERVER 5.7\data\'
<Errcode: 2 - No such file or directory>
0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated.
Please use --explicit_defaults_for_timestamp server option<see documentation for more details>
0 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
...
PS: I've saved the mysqld-init.txt in the Local Disk(C:).
Please guys, I don't have a clue on how to solve this mess. I need to reset the root password and connect MySQL.
Thanks
This question is about half a year old, but I just ran into the same problem this morning. Made several changes at the same time, so I'm not sure which was the actual fix, but, regarding:
mysqld: CAN'T CHANGE DIR TO 'C:Program Files\MySQL\MySQL SERVER 5.7\data\'
I created an empty 'data' directory in the "MySQL SERVER 5.7" folder.
Additionally, I used an 'Administrator: Command Prompt' to execute the command. Finally, I included the "defaults file" specified in the MySQL docs, and fiddled with the order of inputs. I've closed the window now, but I don't believe I actually used "double backslashes".
My working command was:
mysqld.exe --defaults-file="C:\ProgramData\MySQL\MySQL Server 5.7\my.ini"
--init-file="C:\Users\Me\mysql-init.txt"
--console
i was looking this: Copy mysql database from remote server to local computer
And it's the same case as me! but what i need use to connect with the following code:
mysql -u username -p -h remote.site.com
What is this "console"?
Thanks!
EDIT: If there's not possible to pull db by this method, exists some php script that you put db name, server and password and they pull automatically?
Assuming that you have mysql utilities on your machine.
Go to your start menu on your PC and click on "run"
Then when the dos command line come up type in your command.
mysql -u username -p -h your domain.com
If you get an error something like "command not recognized" you will have to first navigate to the mysql bin folder
For example
cd C:\Program Files\MySQL\MySQL Server 5.6\bin
Then execute the mysql..... Command.
Note, the remote server has to accept the connection. If you get a connection rejects you may want to make sure your remote server allow such a connection.
"console" has different names which often mean the same thing:
Terminal window
DOS prompt
Command prompt
Command line
It's the program on your computer which allows to run commands by typing text instead of clicking on icons and buttons.
Friends, I have kept on tying and trying to restore a mysql database from a backup I created with mysqldump. I have been using this code (run in a command prompt Win XP and Win 7)
"C:\Program Files\MySQL\MySQL Server 5.5\mysql --user=root --password=password --host= localhost --port= 3306 --database=dbname < C:/Backup/dbname.sql"
I get "The filename, directory name, or volume lable syntax is incorrect" error messsage. I have googled for this error to no avail as to do with mysql.
*My mysql server is up and running with no problem. (Even the mysqldump command works)
*Problem is the same even if I open the command prompt from C:\Program Files\MySQL\MySQL Server 5.5\mysql
*I have tried to remove "", did not help.
*I have tried to use back slashes () instead of (/), did not help.
For this one, I will really appreciate any help. What is the problem here? what is this filename,directory name.... syntax error?
Thank you.
I think this is because you have quoted the whole command when you only need to quote the program name because there is a space in the path
Also the path for the backup file looks like it has "/" in place of "\"
Should be more like (assuming the options are correct:
"C:\Program Files\MySQL\MySQL Server 5.5\mysql.exe" --user=root --password=password --host= localhost --port=3306 --database=dbname < C:\Backup\dbname.sql
You can quit the file you're trying to execute from the command line and instead log in in MySQL and once inside do:
source C:/Backup/dbname.sql
Open Command Prompt and type this
cd C:\Program Files (x86)\MySQL\MySQL Server 5.5\bin
Press Enter
or,
Directly open this directory "C:\Program Files (x86)\MySQL\MySQL Server 5.5\bin" and Press LEFT SHIFT KEY from keyboard and RIGHT CLICK on the Directory Window.
Type this
mysql -u root -p12345 -h localhost ""DATABASE_NAME"" < e:\tmp.sql
It will work 100% correctly
Hi I have installed MySQL from oracle website, but did not get a "MySQL Command Line" option under MySQL in Programs menu.
So I looked up on this site how to execute sql queries from DOS command prompt.
I found an answer on this site that advised to type in something like: sql root u- p- etc. but this does not work.
Can anyone advise me the syntax to use to go into sql from DOS, or direct me to the answer described above (I cannot locate it)
I use Windows 7 and downloaded the ODBC driver, too.
Many thanks.
Unless MySQL's bin directory is in your PATH variable, you will need to either be in the directory, or write an absolute path to it to execute.
Try something like this (depending on your installation):
cd "C:\Program Files\MySQL\MySQL Server 5.5\bin"
mysql -uroot
Alternatively, you could type this directly:
"C:\Program Files\MySQL\MySQL Server 5.5\bin\mysql.exe" -uroot
cd/
cd wamp
cd bin
cd mysql
cd mysql5.0.51b
#################################
note use your own version of mysql, mine is 5.0.51b
########################################
cd bin
mysql -h localhost -u root -p
////////////////////////////////
note -p that is if u use a password
////////////////////////////////////////
after this line of codes you have this
welcome note telling you the server version of mysql and your connection id
If you navigate to the bin directory of the program you just installed then type "mysql.exe"
Have a look at this guide if you get stuck with the commands
Determine the path of your MySQL installation, and add it to PATH environment variable.
SET PATH=%PATH%;C:\MySQL\bin
The above example assumes MySQL to be installed in C:\MySQL directory.
Once path is set, then you can directly execute
mysql -u root
Which logs into MySQL as root user. The -p flag can be used if password is required
It is required to execute SET PATH every time, hence you may make a batch file.
Whenever I try to start MySQL by typing
> mysql -u root
I get the error
ERROR 2003(HY000): Can't connect to MySQL server on 'localhost' (10061)
How can I solve the problem above? I just downloaded MySQL and unzipped it in the E: drive. I have not done anything else. Do I have to make a connection first? If so, how can I do that?
Here is the ZIP file that I had downloaded: mysql-5.7.15-winx64.zip
Here are the steps to start MYSQL Server (mysql-5.7.15-winx64) for the first time on Windows:
Create a new folder named "data" in MYSQL installation directory (i.e. in the same location as where "bin" directory is located. For me it is: C:\programs\mysql-5.7.15-winx64\mysql-5.7.15-winx64. This location will vary as per the location where you have extracted the MYSQL zip file)
From here I will use my MYSQL folder location as reference. Go to: C:\programs\mysql-5.7.15-winx64\mysql-5.7.15-winx64\bin and execute the command: mysqld --initialize-insecure or mysqld --initialize depending on whether you want the server to generate a random initial password for the 'root'#'localhost' account.
To start the DB, go to: C:\programs\mysql-5.7.15-winx64\mysql-5.7.15-winx64\bin and execute mysqld --console You can see the start-up logs being printed.
To connect to DB, go to: C:\programs\mysql-5.7.15-winx64\mysql-5.7.15-winx64\bin and execute mysql -u root -p. When prompted, Enter password if it has been set or else just hit "Enter" button to connect
The MySQL server can be started manually from the command line. This can be done on any version of Windows.
To start the mysqld server from the command line, you should start a console window (or “DOS window”) and enter this command:
shell> "C:\Program Files\MySQL\MySQL Server 5.0\bin\mysqld"
The path to mysqld may vary depending on the install location of MySQL on your system.
You can stop the MySQL server by executing this command:
shell> "C:\Program Files\MySQL\MySQL Server 5.0\bin\mysqladmin" -u root shutdown
**Note : **
If the MySQL root user account has a password, you need to invoke mysqladmin with the -p option and supply the password when prompted.
This command invokes the MySQL administrative utility mysqladmin to connect to the server and tell it to shut down. The command connects as the MySQL root user, which is the default administrative account in the MySQL grant system. Note that users in the MySQL grant system are wholly independent from any login users under Windows.
If mysqld doesn't start, check the error log to see whether the server wrote any messages there to indicate the cause of the problem. The error log is located in the C:\Program Files\MySQL\MySQL Server 5.0\data directory. It is the file with a suffix of .err. You can also try to start the server as mysqld --console; in this case, you may get some useful information on the screen that may help solve the problem.
The last option is to start mysqld with the --standalone and --debug options. In this case, mysqld writes a log file C:\mysqld.trace that should contain the reason why mysqld doesn't start. See MySQL Internals: Porting to Other Systems.
Via MySQL Official Page
If the command prompt does not work in Windows, try the following:
1) Open services in Windows.
2) Then check the status for Mysql and if you found status nothing or blank then start the mysql service.
3) After then see whether the mysql is start or not .If it shows started then try to check mysql working.
It has worked for me when cmd commands were not working.
Run the command prompt as admin and cd to bin directory of MySQL
Generally it is (C:\Program Files\MySQL\mysql-5.6.36-winx64\bin)
Run command : mysqld --install. (This command will install MySQL services and if services already installed it will prompt.)
Run below commands to start and stop server
To start : net start mysql
To stop : net stop mysql
Run mysql command.
Enjoy !!
maybe
E:\mysql-5.1.39-win32\bin>mysql -u root -p
Type
C:\> "C:\Program Files\MySQL\MySQL Server 5.1\bin\mysqld" --console
to start the sql server and then test the client connection.
I was using MySQL Server 5.5 as a result I was missing the folder which majority of the answers made mention of in the bin folder. What I did instead was the following:
Open Explorer and make your way to C:\Program Files\MySQL\MySQL Server 5.5\bin or your MySQL installation directory.
Run the executable application MySQLInstanceConfig and follow the images below.
This solved my issue and I was able to access the database without any errors.
Start mysql server by command prompt
C:> "C:\Program Files\MySQL\MySQL Server 5.5\bin\mysqld" --console
Or alternative reach up to bin then
mysqld --console
It will start your server.
If you have mysql command line client available
click on it
it show enter your password :
Please enter your password.
Then you can access it.
You also need to configure and start the MySQL server. This will probably help
I tried following steps to run mysql server 5.6 on my windows 8.
Run command prompt as an administrator
go mysql server 5.6 installation directory (in my case: C:\Program Files (x86)\MySQL\MySQL Server 5.6\bin) copy that location
In Command prompt run "cd C:\Program Files (x86)\MySQL\MySQL Server 5.6\bin"
run "mysql -u root"
You need to run the server first. The command you use (in the question) starts a client to connect to the server but the server is not there so there the error.
Since I am not a Windows user (Linux comes equipped) so I might not be the best person to tell you how but I can point to you to a guide and another guide that show you how to get MySQL server up and running in Windows.
After you get that running, you can use the command (in the question) to connect it.
NOTE: You may also try http://www.apachefriends.org/en/xampp.html if you plan to use MySQL for web database development.
Hope this helps.
The error complains about localhost rather than permissions and the current practice in MySQL is to have a bind-address specifying localhost only in a configuration file.
So I don't think it's a password problem - except that you say you 'unzipped' MySQL.
Is that enough installation? What did you download?
Was there any installation step which allowed you to define a root password?
And, as NawaMan said, is the server running?
first thing you need to do is to start the mysql
for that you can use
E:\mysql-5.1.39-win32\bin>net start mysql (only when there a mysql running as service)
then you can execute
E:\mysql-5.1.39-win32\bin>mysql -u root
Run your command prompt as administrator.#
We can start MySQL service from windows command line using the below command.
net start mysql
Command to stop MySql service:
net stop mysql
Disable MySql service:
sc config mysql start= disabled
Command to enable MySql service(to automatically start MySQL service when the system starts up):
sc config mysql start= auto
Command to set the startup type to manual:
sc config mysql start= manual
How to restart MySql service?
There is no direct command to restart a service. You can combine stop and start commands like below.
net stop mysql & net start mysql
I was also having problem with starting MySql server but run command as mention right mark in picture . Its working fine .
mysql -u root -p
After entering this command in terminal, it will ask for password
Enter the password and you are ready to go!
there is one of the best solution do resolve this problem and it is going to work 100%.
as we know that server is a process so treat it like a process go to the task manager
in windows and see for services in task manager in that service see for Mysql and MS80 and try to start it manually by click on it and say run then will take some time.
go to your mysql workbench and click on start/shutdown then try to refresh the server status in server status option. it will load up thats it.
1.Open a command prompt as Administrator.
2.Go to MySQL installed bin directory in program files.
3.Copy the location of the bin directory from windows explorer.
4.In command prompt type cd and (paste the location) and do enter.
5.Type mysqld --initialize
6.Open services from the windows menu and sort the list by name.
7.Right-click Mysql and click start.
use the command "mysql -u root -p" in the bin folder path.
and give the MY SQL password which you have set earlier.