<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.r512.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Bacchas</id>
	<title>rbachwiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://www.r512.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Bacchas"/>
	<link rel="alternate" type="text/html" href="https://www.r512.com/index.php/Special:Contributions/Bacchas"/>
	<updated>2026-04-03T16:32:04Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.37.1</generator>
	<entry>
		<id>https://www.r512.com/index.php?title=Python_Environment_Setup&amp;diff=2925</id>
		<title>Python Environment Setup</title>
		<link rel="alternate" type="text/html" href="https://www.r512.com/index.php?title=Python_Environment_Setup&amp;diff=2925"/>
		<updated>2026-01-05T16:52:10Z</updated>

		<summary type="html">&lt;p&gt;Bacchas: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Create the Environment with a Unique Name==&lt;br /&gt;
*Instead of the generic .venv, give your Windows environment a name that clearly identifies it. In your project&amp;#039;s root terminal, run:&lt;br /&gt;
 python -m venv .venv_pc &lt;br /&gt;
*This creates a new folder named &amp;lt;code&amp;gt;.venv_pc &amp;lt;/code&amp;gt;in your project. Your existing Mac folder &amp;lt;code&amp;gt;(e.g., .venv or .venv_mac) &amp;lt;/code&amp;gt;will remain completely untouched.&lt;br /&gt;
==Set VS Code to Use the New PC Environment==&lt;br /&gt;
* You must tell VS Code on your PC to use this specific folder instead of the one from your Mac:&lt;br /&gt;
**Press&amp;lt;code&amp;gt; Ctrl + Shift + P&amp;lt;/code&amp;gt; to open the Command Palette.&lt;br /&gt;
*Type and select Python: Select Interpreter.&lt;br /&gt;
*Choose the one that points to your new folder: &amp;lt;code&amp;gt;(&amp;#039;.venv_pc&amp;#039;: venv).&amp;lt;/code&amp;gt;&lt;br /&gt;
*If it doesn&amp;#039;t appear, select Enter interpreter path... and browse to .venv_pc\Scripts\python.exe.&lt;br /&gt;
= Sync Libraries via requirements.txt =&lt;br /&gt;
*Since you have a new, empty environment, you need to install your project&amp;#039;s dependencies:&lt;br /&gt;
* On your Mac (before switching): &amp;lt;code&amp;gt;Run pip freeze &amp;gt; requirements.txt&amp;lt;/code&amp;gt; to save a list of your current libraries.&lt;br /&gt;
* On your PC: Activate the new environment with &amp;lt;code&amp;gt;.venv_pc\Scripts\activate &amp;lt;/code&amp;gt; and then run&lt;br /&gt;
 pip install -r requirements.txt.&lt;br /&gt;
= Prevent Future Sync Issues =&lt;br /&gt;
*To ensure your Mac environment doesn&amp;#039;t accidentally get messed up by your PC (or vice versa), add both environment names to your project&amp;#039;s &amp;lt;code&amp;gt;.gitignore&amp;lt;/code&amp;gt; file:&lt;br /&gt;
 &amp;lt;pre&amp;gt;&lt;br /&gt;
.venv/&lt;br /&gt;
.venv_pc/&lt;br /&gt;
.venv_mac/&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Bacchas</name></author>
	</entry>
	<entry>
		<id>https://www.r512.com/index.php?title=Python_Environment_Setup&amp;diff=2924</id>
		<title>Python Environment Setup</title>
		<link rel="alternate" type="text/html" href="https://www.r512.com/index.php?title=Python_Environment_Setup&amp;diff=2924"/>
		<updated>2026-01-05T16:50:34Z</updated>

		<summary type="html">&lt;p&gt;Bacchas: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Create the Environment with a Unique Name==&lt;br /&gt;
*Instead of the generic .venv, give your Windows environment a name that clearly identifies it. In your project&amp;#039;s root terminal, run:&lt;br /&gt;
 python -m venv .venv_pc &lt;br /&gt;
*This creates a new folder named &amp;lt;code&amp;gt;.venv_pc &amp;lt;/code&amp;gt;in your project. Your existing Mac folder &amp;lt;code&amp;gt;(e.g., .venv or .venv_mac) &amp;lt;/code&amp;gt;will remain completely untouched.&lt;br /&gt;
==Set VS Code to Use the New PC Environment==&lt;br /&gt;
* You must tell VS Code on your PC to use this specific folder instead of the one from your Mac:&lt;br /&gt;
**Press&amp;lt;code&amp;gt; Ctrl + Shift + P&amp;lt;/code&amp;gt; to open the Command Palette.&lt;br /&gt;
*Type and select Python: Select Interpreter.&lt;br /&gt;
*Choose the one that points to your new folder: &amp;lt;code&amp;gt;(&amp;#039;.venv_pc&amp;#039;: venv).&amp;lt;/code&amp;gt;&lt;br /&gt;
*If it doesn&amp;#039;t appear, select Enter interpreter path... and browse to .venv_pc\Scripts\python.exe.&lt;br /&gt;
= Sync Libraries via requirements.txt =&lt;br /&gt;
*Since you have a new, empty environment, you need to install your project&amp;#039;s dependencies:&lt;br /&gt;
* On your Mac (before switching): &amp;lt;code&amp;gt;Run pip freeze &amp;gt; requirements.txt&amp;lt;/code&amp;gt; to save a list of your current libraries.&lt;br /&gt;
* On your PC: Activate the new environment with &amp;lt;code&amp;gt;.venv_pc\Scripts\activate &amp;lt;/code&amp;gt; and then run&lt;br /&gt;
 pip install -r requirements.txt.&lt;/div&gt;</summary>
		<author><name>Bacchas</name></author>
	</entry>
	<entry>
		<id>https://www.r512.com/index.php?title=Python_Environment_Setup&amp;diff=2923</id>
		<title>Python Environment Setup</title>
		<link rel="alternate" type="text/html" href="https://www.r512.com/index.php?title=Python_Environment_Setup&amp;diff=2923"/>
		<updated>2026-01-05T16:21:28Z</updated>

		<summary type="html">&lt;p&gt;Bacchas: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Create the Environment with a Unique Name==&lt;br /&gt;
*Instead of the generic .venv, give your Windows environment a name that clearly identifies it. In your project&amp;#039;s root terminal, run:&lt;br /&gt;
 python -m venv .venv_pc &lt;br /&gt;
*This creates a new folder named &amp;lt;code&amp;gt;.venv_pc &amp;lt;/code&amp;gt;in your project. Your existing Mac folder &amp;lt;code&amp;gt;(e.g., .venv or .venv_mac) &amp;lt;/code&amp;gt;will remain completely untouched.&lt;br /&gt;
==Set VS Code to Use the New PC Environment==&lt;br /&gt;
* You must tell VS Code on your PC to use this specific folder instead of the one from your Mac:&lt;br /&gt;
**Press&amp;lt;code&amp;gt; Ctrl + Shift + P&amp;lt;/code&amp;gt; to open the Command Palette.&lt;br /&gt;
*Type and select Python: Select Interpreter.&lt;br /&gt;
*Choose the one that points to your new folder: &amp;lt;code&amp;gt;(&amp;#039;.venv_pc&amp;#039;: venv).&amp;lt;/code&amp;gt;&lt;br /&gt;
If it doesn&amp;#039;t appear, select Enter interpreter path... and browse to .venv_pc\Scripts\python.exe.&lt;/div&gt;</summary>
		<author><name>Bacchas</name></author>
	</entry>
	<entry>
		<id>https://www.r512.com/index.php?title=Python_Environment_Setup&amp;diff=2922</id>
		<title>Python Environment Setup</title>
		<link rel="alternate" type="text/html" href="https://www.r512.com/index.php?title=Python_Environment_Setup&amp;diff=2922"/>
		<updated>2026-01-05T16:20:59Z</updated>

		<summary type="html">&lt;p&gt;Bacchas: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Create the Environment with a Unique Name==&lt;br /&gt;
*Instead of the generic .venv, give your Windows environment a name that clearly identifies it. In your project&amp;#039;s root terminal, run:&lt;br /&gt;
 python -m venv .venv_pc &lt;br /&gt;
*This creates a new folder named &amp;lt;code&amp;gt;.venv_pc &amp;lt;/code&amp;gt;in your project. Your existing Mac folder &amp;lt;code&amp;gt;(e.g., .venv or .venv_mac) &amp;lt;/code&amp;gt;will remain completely untouched.&lt;br /&gt;
==Set VS Code to Use the New PC Environment==&lt;br /&gt;
* You must tell VS Code on your PC to use this specific folder instead of the one from your Mac:&lt;br /&gt;
**Press Ctrl + Shift + P to open the Command Palette.&lt;br /&gt;
*Type and select Python: Select Interpreter.&lt;br /&gt;
*Choose the one that points to your new folder: &amp;lt;code&amp;gt;(&amp;#039;.venv_pc&amp;#039;: venv).&amp;lt;/code&amp;gt;&lt;br /&gt;
If it doesn&amp;#039;t appear, select Enter interpreter path... and browse to .venv_pc\Scripts\python.exe.&lt;/div&gt;</summary>
		<author><name>Bacchas</name></author>
	</entry>
	<entry>
		<id>https://www.r512.com/index.php?title=Python_Environment_Setup&amp;diff=2921</id>
		<title>Python Environment Setup</title>
		<link rel="alternate" type="text/html" href="https://www.r512.com/index.php?title=Python_Environment_Setup&amp;diff=2921"/>
		<updated>2026-01-05T16:20:28Z</updated>

		<summary type="html">&lt;p&gt;Bacchas: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Create the Environment with a Unique Name==&lt;br /&gt;
*Instead of the generic .venv, give your Windows environment a name that clearly identifies it. In your project&amp;#039;s root terminal, run:&lt;br /&gt;
 python -m venv .venv_pc &lt;br /&gt;
*This creates a new folder named &amp;lt;code&amp;gt;.venv_pc &amp;lt;/code&amp;gt;in your project. Your existing Mac folder &amp;lt;code&amp;gt;(e.g., .venv or .venv_mac) &amp;lt;/code&amp;gt;will remain completely untouched.&lt;br /&gt;
==Set VS Code to Use the New PC Environment==&lt;br /&gt;
* You must tell VS Code on your PC to use this specific folder instead of the one from your Mac:&lt;br /&gt;
-Press Ctrl + Shift + P to open the Command Palette.&lt;br /&gt;
*Type and select Python: Select Interpreter.&lt;br /&gt;
*Choose the one that points to your new folder: &amp;lt;code&amp;gt;(&amp;#039;.venv_pc&amp;#039;: venv).&amp;lt;/code&amp;gt;&lt;br /&gt;
If it doesn&amp;#039;t appear, select Enter interpreter path... and browse to .venv_pc\Scripts\python.exe.&lt;/div&gt;</summary>
		<author><name>Bacchas</name></author>
	</entry>
	<entry>
		<id>https://www.r512.com/index.php?title=Python_Environment_Setup&amp;diff=2920</id>
		<title>Python Environment Setup</title>
		<link rel="alternate" type="text/html" href="https://www.r512.com/index.php?title=Python_Environment_Setup&amp;diff=2920"/>
		<updated>2026-01-05T16:18:39Z</updated>

		<summary type="html">&lt;p&gt;Bacchas: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Create the Environment with a Unique Name==&lt;br /&gt;
*Instead of the generic .venv, give your Windows environment a name that clearly identifies it. In your project&amp;#039;s root terminal, run:&lt;br /&gt;
 python -m venv .venv_pc &lt;br /&gt;
*This creates a new folder named &amp;lt;code&amp;gt;.venv_pc &amp;lt;/code&amp;gt;in your project. Your existing Mac folder &amp;lt;code&amp;gt;(e.g., .venv or .venv_mac) &amp;lt;/code&amp;gt;will remain completely untouched.&lt;/div&gt;</summary>
		<author><name>Bacchas</name></author>
	</entry>
	<entry>
		<id>https://www.r512.com/index.php?title=Python_Environment_Setup&amp;diff=2919</id>
		<title>Python Environment Setup</title>
		<link rel="alternate" type="text/html" href="https://www.r512.com/index.php?title=Python_Environment_Setup&amp;diff=2919"/>
		<updated>2026-01-05T16:18:04Z</updated>

		<summary type="html">&lt;p&gt;Bacchas: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Create the Environment with a Unique Name==&lt;br /&gt;
*Instead of the generic .venv, give your Windows environment a name that clearly identifies it. In your project&amp;#039;s root terminal, run:&lt;br /&gt;
 python -m venv .venv_pc &lt;br /&gt;
*This creates a new folder named &amp;lt;code&amp;gt;.venv_pc &amp;lt;/code&amp;gt;in your project. Your existing Mac folder (e.g., .venv or .venv_mac) will remain completely untouched.&lt;/div&gt;</summary>
		<author><name>Bacchas</name></author>
	</entry>
	<entry>
		<id>https://www.r512.com/index.php?title=Python_Environment_Setup&amp;diff=2918</id>
		<title>Python Environment Setup</title>
		<link rel="alternate" type="text/html" href="https://www.r512.com/index.php?title=Python_Environment_Setup&amp;diff=2918"/>
		<updated>2026-01-05T16:03:12Z</updated>

		<summary type="html">&lt;p&gt;Bacchas: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Create the Environment with a Unique Name==&lt;br /&gt;
*Instead of the generic .venv, give your Windows environment a name that clearly identifies it. In your project&amp;#039;s root terminal, run:&lt;br /&gt;
 python -m venv .venv_pc &lt;br /&gt;
*This creates a new folder named .venv_pc in your project. Your existing Mac folder (e.g., .venv or .venv_mac) will remain completely untouched.&lt;/div&gt;</summary>
		<author><name>Bacchas</name></author>
	</entry>
	<entry>
		<id>https://www.r512.com/index.php?title=Python_Environment_Setup&amp;diff=2917</id>
		<title>Python Environment Setup</title>
		<link rel="alternate" type="text/html" href="https://www.r512.com/index.php?title=Python_Environment_Setup&amp;diff=2917"/>
		<updated>2026-01-05T15:47:35Z</updated>

		<summary type="html">&lt;p&gt;Bacchas: Created page with &amp;quot;==Create the Environment with a Unique Name== *Instead of the generic .venv, give your Windows environment a name that clearly identifies it. In your project&amp;#039;s root terminal, run: python -m venv .venv_pc  *This creates a new folder named .venv_pc in your project. Your existing Mac folder (e.g., .venv or .venv_mac) will remain completely untouched.&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Create the Environment with a Unique Name==&lt;br /&gt;
*Instead of the generic .venv, give your Windows environment a name that clearly identifies it. In your project&amp;#039;s root terminal, run:&lt;br /&gt;
python -m venv .venv_pc &lt;br /&gt;
*This creates a new folder named .venv_pc in your project. Your existing Mac folder (e.g., .venv or .venv_mac) will remain completely untouched.&lt;/div&gt;</summary>
		<author><name>Bacchas</name></author>
	</entry>
	<entry>
		<id>https://www.r512.com/index.php?title=Python&amp;diff=2916</id>
		<title>Python</title>
		<link rel="alternate" type="text/html" href="https://www.r512.com/index.php?title=Python&amp;diff=2916"/>
		<updated>2026-01-05T15:46:10Z</updated>

		<summary type="html">&lt;p&gt;Bacchas: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=[[Python Environment Setup]]=&lt;br /&gt;
=[[Convert .Py to .exe]]=&lt;br /&gt;
=[[Fix Python Errors]]=&lt;br /&gt;
=[[Python Software installation]]=&lt;br /&gt;
=[[Object and Data Structure Basics]]=&lt;br /&gt;
=[[Perform IO with Text Files]]=&lt;br /&gt;
=[[Control Flow, if statements etc..]]=&lt;br /&gt;
=[[Python Problems and Solutions]]=&lt;br /&gt;
=[[Python Functions]]=&lt;br /&gt;
=[[Python Web Scraping]]=&lt;br /&gt;
=[[Python Data Mining]]=&lt;br /&gt;
=[[Coursera Google Python Automation Course]]=&lt;br /&gt;
=[[Python Excel Related]]=&lt;br /&gt;
=[[Python Copying File and Directories ]]=&lt;/div&gt;</summary>
		<author><name>Bacchas</name></author>
	</entry>
	<entry>
		<id>https://www.r512.com/index.php?title=Python&amp;diff=2915</id>
		<title>Python</title>
		<link rel="alternate" type="text/html" href="https://www.r512.com/index.php?title=Python&amp;diff=2915"/>
		<updated>2026-01-05T15:45:57Z</updated>

		<summary type="html">&lt;p&gt;Bacchas: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=[[Python Environment Setup]]==&lt;br /&gt;
=[[Convert .Py to .exe]]=&lt;br /&gt;
=[[Fix Python Errors]]=&lt;br /&gt;
=[[Python Software installation]]=&lt;br /&gt;
=[[Object and Data Structure Basics]]=&lt;br /&gt;
=[[Perform IO with Text Files]]=&lt;br /&gt;
=[[Control Flow, if statements etc..]]=&lt;br /&gt;
=[[Python Problems and Solutions]]=&lt;br /&gt;
=[[Python Functions]]=&lt;br /&gt;
=[[Python Web Scraping]]=&lt;br /&gt;
=[[Python Data Mining]]=&lt;br /&gt;
=[[Coursera Google Python Automation Course]]=&lt;br /&gt;
=[[Python Excel Related]]=&lt;br /&gt;
=[[Python Copying File and Directories ]]=&lt;/div&gt;</summary>
		<author><name>Bacchas</name></author>
	</entry>
	<entry>
		<id>https://www.r512.com/index.php?title=.PS1_To_.exe&amp;diff=2914</id>
		<title>.PS1 To .exe</title>
		<link rel="alternate" type="text/html" href="https://www.r512.com/index.php?title=.PS1_To_.exe&amp;diff=2914"/>
		<updated>2025-12-02T19:06:36Z</updated>

		<summary type="html">&lt;p&gt;Bacchas: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Converting a PowerShell script (.ps1) to an executable (.exe) can be achieved using tools like PS2EXE or IExpress.==&lt;br /&gt;
 Install-Module -Name PS2EXE&lt;br /&gt;
*Convert the script: Use the Invoke-PS2EXE command, specifying the source .ps1 file and the desired output .exe file path. For example:&lt;br /&gt;
 Invoke-PS2EXE -File C:\Path\To\YourScript.ps1 -OutputFile C:\Path\To\YourExecutable.exe&lt;br /&gt;
*You can also include parameters like -NoConsole to prevent a PowerShell console from appearing when the .exe is run, or -IconFile to specify a custom icon.&lt;/div&gt;</summary>
		<author><name>Bacchas</name></author>
	</entry>
	<entry>
		<id>https://www.r512.com/index.php?title=.PS1_To_.exe&amp;diff=2913</id>
		<title>.PS1 To .exe</title>
		<link rel="alternate" type="text/html" href="https://www.r512.com/index.php?title=.PS1_To_.exe&amp;diff=2913"/>
		<updated>2025-12-02T19:05:11Z</updated>

		<summary type="html">&lt;p&gt;Bacchas: Created page with &amp;quot;==Converting a PowerShell script (.ps1) to an executable (.exe) can be achieved using tools like PS2EXE or IExpress.==&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Converting a PowerShell script (.ps1) to an executable (.exe) can be achieved using tools like PS2EXE or IExpress.==&lt;/div&gt;</summary>
		<author><name>Bacchas</name></author>
	</entry>
	<entry>
		<id>https://www.r512.com/index.php?title=PowerShell&amp;diff=2912</id>
		<title>PowerShell</title>
		<link rel="alternate" type="text/html" href="https://www.r512.com/index.php?title=PowerShell&amp;diff=2912"/>
		<updated>2025-12-02T19:04:57Z</updated>

		<summary type="html">&lt;p&gt;Bacchas: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==[[.PS1 To .exe]]==&lt;br /&gt;
==[[Powershell Fundamentals]]==&lt;br /&gt;
==[[Useful PowerShell Commands]]==&lt;br /&gt;
==[[POWERSHELL FILEBASED OPERATIONS]]==&lt;br /&gt;
==[[Powershell Network Commands]]==&lt;br /&gt;
==[[PowerShell Comparison Operators]]==&lt;/div&gt;</summary>
		<author><name>Bacchas</name></author>
	</entry>
	<entry>
		<id>https://www.r512.com/index.php?title=Convert_.Py_to_.exe&amp;diff=2911</id>
		<title>Convert .Py to .exe</title>
		<link rel="alternate" type="text/html" href="https://www.r512.com/index.php?title=Convert_.Py_to_.exe&amp;diff=2911"/>
		<updated>2025-12-02T16:50:02Z</updated>

		<summary type="html">&lt;p&gt;Bacchas: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;h2&amp;gt; Converting a Python script (.py) to an executable (.exe) file for Windows can be achieved using tools like PyInstaller&amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Using PyInstaller (Command Line):&amp;#039;&amp;#039;&amp;#039; &amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Install PyInstaller: Open your command prompt or terminal and execute:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 pip install pyinstaller&lt;br /&gt;
* Navigate to your script&amp;#039;s directory: Use the cd command to change the directory to where your Python script is located. For example&lt;br /&gt;
 cd C:\Users\YourUser\Documents\PythonProjects&lt;br /&gt;
* Run PyInstaller: Execute the following command, replacing your_script_name.py with the actual name of your Python file:&lt;br /&gt;
 pyinstaller your_script_name.py&lt;br /&gt;
*To create a single executable file (instead of a directory with dependencies), add the --onefile flag:&lt;br /&gt;
 pyinstaller --onefile your_script_name.py&lt;br /&gt;
&lt;br /&gt;
*pyinstaller --onefile your_script_name.py&lt;/div&gt;</summary>
		<author><name>Bacchas</name></author>
	</entry>
	<entry>
		<id>https://www.r512.com/index.php?title=Convert_.Py_to_.exe&amp;diff=2910</id>
		<title>Convert .Py to .exe</title>
		<link rel="alternate" type="text/html" href="https://www.r512.com/index.php?title=Convert_.Py_to_.exe&amp;diff=2910"/>
		<updated>2025-12-02T16:48:13Z</updated>

		<summary type="html">&lt;p&gt;Bacchas: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;h2&amp;gt; Converting a Python script (.py) to an executable (.exe) file for Windows can be achieved using tools like PyInstaller&amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Using PyInstaller (Command Line):&amp;#039;&amp;#039;&amp;#039; &amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Install PyInstaller: Open your command prompt or terminal and execute:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 pip install pyinstaller&lt;br /&gt;
* Navigate to your script&amp;#039;s directory: Use the cd command to change the directory to where your Python script is located. For example&lt;/div&gt;</summary>
		<author><name>Bacchas</name></author>
	</entry>
	<entry>
		<id>https://www.r512.com/index.php?title=Convert_.Py_to_.exe&amp;diff=2909</id>
		<title>Convert .Py to .exe</title>
		<link rel="alternate" type="text/html" href="https://www.r512.com/index.php?title=Convert_.Py_to_.exe&amp;diff=2909"/>
		<updated>2025-12-02T16:47:52Z</updated>

		<summary type="html">&lt;p&gt;Bacchas: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;h2&amp;gt; Converting a Python script (.py) to an executable (.exe) file for Windows can be achieved using tools like PyInstaller&amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Using PyInstaller (Command Line):&amp;#039;&amp;#039;&amp;#039; &amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Install PyInstaller: Open your command prompt or terminal and execute:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 pip install pyinstaller&lt;/div&gt;</summary>
		<author><name>Bacchas</name></author>
	</entry>
	<entry>
		<id>https://www.r512.com/index.php?title=Convert_.Py_to_.exe&amp;diff=2908</id>
		<title>Convert .Py to .exe</title>
		<link rel="alternate" type="text/html" href="https://www.r512.com/index.php?title=Convert_.Py_to_.exe&amp;diff=2908"/>
		<updated>2025-12-02T16:47:07Z</updated>

		<summary type="html">&lt;p&gt;Bacchas: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;h2&amp;gt; Converting a Python script (.py) to an executable (.exe) file for Windows can be achieved using tools like PyInstaller&amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Using PyInstaller (Command Line):&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Install PyInstaller: Open your command prompt or terminal and execute:&amp;#039;&amp;#039;&amp;#039;&lt;/div&gt;</summary>
		<author><name>Bacchas</name></author>
	</entry>
	<entry>
		<id>https://www.r512.com/index.php?title=Convert_.Py_to_.exe&amp;diff=2907</id>
		<title>Convert .Py to .exe</title>
		<link rel="alternate" type="text/html" href="https://www.r512.com/index.php?title=Convert_.Py_to_.exe&amp;diff=2907"/>
		<updated>2025-12-02T16:43:00Z</updated>

		<summary type="html">&lt;p&gt;Bacchas: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;## Converting a Python script (.py) to an executable (.exe) file for Windows can be achieved using tools like PyInstaller&lt;/div&gt;</summary>
		<author><name>Bacchas</name></author>
	</entry>
	<entry>
		<id>https://www.r512.com/index.php?title=Convert_.Py_to_.exe&amp;diff=2906</id>
		<title>Convert .Py to .exe</title>
		<link rel="alternate" type="text/html" href="https://www.r512.com/index.php?title=Convert_.Py_to_.exe&amp;diff=2906"/>
		<updated>2025-12-02T16:42:20Z</updated>

		<summary type="html">&lt;p&gt;Bacchas: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;##Converting a Python script (.py) to an executable (.exe) file for Windows can be achieved using tools like PyInstaller&lt;/div&gt;</summary>
		<author><name>Bacchas</name></author>
	</entry>
	<entry>
		<id>https://www.r512.com/index.php?title=Convert_.Py_to_.exe&amp;diff=2905</id>
		<title>Convert .Py to .exe</title>
		<link rel="alternate" type="text/html" href="https://www.r512.com/index.php?title=Convert_.Py_to_.exe&amp;diff=2905"/>
		<updated>2025-12-02T16:42:01Z</updated>

		<summary type="html">&lt;p&gt;Bacchas: Created page with &amp;quot;#Converting a Python script (.py) to an executable (.exe) file for Windows can be achieved using tools like PyInstaller&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#Converting a Python script (.py) to an executable (.exe) file for Windows can be achieved using tools like PyInstaller&lt;/div&gt;</summary>
		<author><name>Bacchas</name></author>
	</entry>
	<entry>
		<id>https://www.r512.com/index.php?title=Python&amp;diff=2904</id>
		<title>Python</title>
		<link rel="alternate" type="text/html" href="https://www.r512.com/index.php?title=Python&amp;diff=2904"/>
		<updated>2025-12-02T16:41:22Z</updated>

		<summary type="html">&lt;p&gt;Bacchas: /* Convert .Py to .exe= */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=[[Convert .Py to .exe]]=&lt;br /&gt;
&lt;br /&gt;
=[[Fix Python Errors]]=&lt;br /&gt;
=[[Python Software installation]]=&lt;br /&gt;
=[[Object and Data Structure Basics]]=&lt;br /&gt;
=[[Perform IO with Text Files]]=&lt;br /&gt;
=[[Control Flow, if statements etc..]]=&lt;br /&gt;
=[[Python Problems and Solutions]]=&lt;br /&gt;
=[[Python Functions]]=&lt;br /&gt;
=[[Python Web Scraping]]=&lt;br /&gt;
=[[Python Data Mining]]=&lt;br /&gt;
=[[Coursera Google Python Automation Course]]=&lt;br /&gt;
=[[Python Excel Related]]=&lt;br /&gt;
=[[Python Copying File and Directories ]]=&lt;/div&gt;</summary>
		<author><name>Bacchas</name></author>
	</entry>
	<entry>
		<id>https://www.r512.com/index.php?title=Python&amp;diff=2903</id>
		<title>Python</title>
		<link rel="alternate" type="text/html" href="https://www.r512.com/index.php?title=Python&amp;diff=2903"/>
		<updated>2025-12-02T16:41:14Z</updated>

		<summary type="html">&lt;p&gt;Bacchas: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=[[Convert .Py to .exe]]==&lt;br /&gt;
=[[Fix Python Errors]]=&lt;br /&gt;
=[[Python Software installation]]=&lt;br /&gt;
=[[Object and Data Structure Basics]]=&lt;br /&gt;
=[[Perform IO with Text Files]]=&lt;br /&gt;
=[[Control Flow, if statements etc..]]=&lt;br /&gt;
=[[Python Problems and Solutions]]=&lt;br /&gt;
=[[Python Functions]]=&lt;br /&gt;
=[[Python Web Scraping]]=&lt;br /&gt;
=[[Python Data Mining]]=&lt;br /&gt;
=[[Coursera Google Python Automation Course]]=&lt;br /&gt;
=[[Python Excel Related]]=&lt;br /&gt;
=[[Python Copying File and Directories ]]=&lt;/div&gt;</summary>
		<author><name>Bacchas</name></author>
	</entry>
	<entry>
		<id>https://www.r512.com/index.php?title=Operators&amp;diff=2902</id>
		<title>Operators</title>
		<link rel="alternate" type="text/html" href="https://www.r512.com/index.php?title=Operators&amp;diff=2902"/>
		<updated>2025-12-01T20:01:36Z</updated>

		<summary type="html">&lt;p&gt;Bacchas: /* Default Parameters = */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==ES6 Spread Operator==&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;ES6 Equivalent Spread Operator&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 const sum3 = addFourAges(...ages);&lt;br /&gt;
 // the ... means the ages array is expanded into individual components.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; Join two Arrays &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 const arrayOne= [&amp;#039;hello&amp;#039;, &amp;#039;two&amp;#039;];&lt;br /&gt;
 const arrayTwo = [&amp;#039;three&amp;#039;, &amp;#039;four&amp;#039;];&lt;br /&gt;
 const arrayThree = [...arrayOne, ...arrayTow];&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; Looping through all elements and changing the color &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 const h = document.querySelector(h1)&lt;br /&gt;
 const boxes = documwnt.querySelectorAll(&amp;#039;.box&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
 const all = [h, ...boxes];&lt;br /&gt;
 Array.form(all).forEach(cur=&amp;gt; cur.style.color=&amp;#039;purple&amp;#039;) // returns an array&lt;br /&gt;
&lt;br /&gt;
== Rest Parameter ==&lt;br /&gt;
 function isFullAge(...years){&lt;br /&gt;
 years.forEach(cur=&amp;gt; (216-cur)&amp;gt;=18);&lt;br /&gt;
 }&lt;br /&gt;
  isFullAge(1990,1921,1967);&lt;br /&gt;
&lt;br /&gt;
== Default Parameters ===&lt;br /&gt;
 function Person(first, last = &amp;#039;lastname&amp;#039;){&lt;br /&gt;
 this.firstname = first;&lt;br /&gt;
 this.lastname = last;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
== Maps ==&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; New key value data structure&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
const question = new Map();&lt;br /&gt;
question.set(&amp;#039;question&amp;#039;, &amp;#039;what is&amp;#039;);&lt;br /&gt;
question.set(1,&amp;#039;es5);&lt;br /&gt;
question.set(2, &amp;#039;es6&amp;#039;);&lt;br /&gt;
question.set(3, &amp;#039;ES2015&amp;#039;);&lt;br /&gt;
question.set(&amp;#039;correct&amp;#039;, 3);&lt;br /&gt;
question.set(True, &amp;#039;Correct Answer&amp;#039;);&lt;br /&gt;
question.set(false, &amp;#039;wrong&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
// Retrieve DAta&lt;br /&gt;
question.get(&amp;#039;question&amp;#039;)&lt;br /&gt;
// get size&lt;br /&gt;
question.size;&lt;br /&gt;
&lt;br /&gt;
// delete &lt;br /&gt;
question.delete(2);&lt;br /&gt;
&lt;br /&gt;
// delete All&lt;br /&gt;
question.clear();&lt;br /&gt;
&lt;br /&gt;
// loop&lt;br /&gt;
&lt;br /&gt;
question.forEach((value,key)=&amp;gt; console.log(`this ${key}, and its set ot ${vlaue})&lt;br /&gt;
&lt;br /&gt;
// Another Way to Loop&lt;br /&gt;
for(let[key, value]of question.entries()){&lt;br /&gt;
console.log(`this ${key}, and its set ot ${vlaue});&lt;br /&gt;
if(typeof(key)=== &amp;#039;number&amp;#039;){&lt;br /&gt;
console.log(`Answer ${key}, and its set ot ${vlaue});&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
==[[#top|Back To Top]]-[[Main_Page| Home]] - [[Java Script|Category]]==&lt;/div&gt;</summary>
		<author><name>Bacchas</name></author>
	</entry>
	<entry>
		<id>https://www.r512.com/index.php?title=MYSQL_DATABASE_RESTORE&amp;diff=2901</id>
		<title>MYSQL DATABASE RESTORE</title>
		<link rel="alternate" type="text/html" href="https://www.r512.com/index.php?title=MYSQL_DATABASE_RESTORE&amp;diff=2901"/>
		<updated>2025-10-07T15:37:04Z</updated>

		<summary type="html">&lt;p&gt;Bacchas: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Restore Database==&lt;br /&gt;
&amp;lt;p style=&amp;quot;background-color: #77a8f7; font-weight: bold; font-size: 1.2rem;&amp;quot;&amp;gt; I used this to restore r512 from the dumped .sql file in 2025 &amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p style=&amp;quot;font-weight: bold;font-size: 1.3rem&amp;quot;&amp;gt; I tried to restore it using phpmyadmin, but it did not work, got many errors. probably because it was a raw sql dump backup. The target database must already exist. if it doesn&amp;#039;t, create it first&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* log into mysql&lt;br /&gt;
 CREATE DATABASE your_database_name;&lt;br /&gt;
&lt;br /&gt;
 mysql&lt;br /&gt;
 use databasename;&lt;br /&gt;
&lt;br /&gt;
 SOURCE /path/to/file/file.sql;&lt;br /&gt;
&amp;lt;hr /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;h4 class=&amp;quot;yellowbackground&amp;quot;&amp;gt;Script to import a CSV File into an existing Database&amp;lt;/h4&amp;gt; ==&lt;br /&gt;
&amp;lt;p style=&amp;quot;background-color: #77a8f7; font-weight: bold; font-size: 1.2rem;&amp;quot;&amp;gt;The csv file has to be in a specific directory. /var/lib/mysql-files/&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p style=&amp;quot;background-color: #77a8f7; font-weight: bold; font-size: 1.2rem;&amp;quot;&amp;gt;The table has to already exist &amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
mysql kartest &amp;lt;&amp;lt;EOF&lt;br /&gt;
truncate table songs;&lt;br /&gt;
load data infile &amp;#039;/var/lib/mysql-files/songs.csv&amp;#039;&lt;br /&gt;
into table songs&lt;br /&gt;
fields terminated by &amp;#039;|&amp;#039;&lt;br /&gt;
enclosed by &amp;#039;&amp;quot;&amp;#039;&lt;br /&gt;
lines terminated by &amp;#039;\n&amp;#039;&lt;br /&gt;
ignore 1 rows;&lt;br /&gt;
EOF&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Copy csv file to a dir and run script on server ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
fxcopy=&amp;quot;/mnt/c/Users/john/Dropbox/Shining Cabinet/My Stuff/sqlitedb&amp;quot;&lt;br /&gt;
scp -i ~/.ssh/linode &amp;quot;$fxcopy/filename.csv&amp;quot; 1.1.1.1:/var/lib/mysql-files/&lt;br /&gt;
sleep 4&lt;br /&gt;
ssh -i ~/.ssh/linode root@1.1.1.1 /var/www/scripts/import.sh&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Fixing error connecting to database from AppSheet ==&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; The permission has to be fixed to the old version in mysql server &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
 ALTER USER &amp;#039;username&amp;#039;@&amp;#039;%&amp;#039; IDENTIFIED WITH mysql_native_password BY &amp;#039;password&amp;#039;;&lt;br /&gt;
 FLUSH PRIVILEGES;&lt;br /&gt;
== Fix error where script to load the csv file would not execute on server===&lt;br /&gt;
&amp;lt;p class=&amp;quot;subhead&amp;quot;&amp;gt;Edit the /etc/mysql/my.cnf file &amp;lt;/p&amp;gt;&lt;br /&gt;
 [mysqld]&lt;br /&gt;
 secure-file-priv=&amp;quot;/var/lib/mysql-files&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; you may have to add the line if it doesn&amp;#039;t exist&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
[[#MySql Commands My Fav|Back To Top]]-[[Main_Page| Home]]&lt;br /&gt;
[[Category:Mysql]]&lt;/div&gt;</summary>
		<author><name>Bacchas</name></author>
	</entry>
	<entry>
		<id>https://www.r512.com/index.php?title=MYSQL_COMMANDS&amp;diff=2900</id>
		<title>MYSQL COMMANDS</title>
		<link rel="alternate" type="text/html" href="https://www.r512.com/index.php?title=MYSQL_COMMANDS&amp;diff=2900"/>
		<updated>2025-10-07T14:26:37Z</updated>

		<summary type="html">&lt;p&gt;Bacchas: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==MySql Commands My Fav ==&lt;br /&gt;
&lt;br /&gt;
Find and Replace the word &amp;quot;GaGa, Ladyy&amp;quot; in Artists and replace with &amp;quot;Lady GaGa&lt;br /&gt;
&lt;br /&gt;
 UPDATE Karaoke set Artists = replace(Artists, &amp;quot;GaGa, Lady&amp;quot;, &amp;quot;Lady GaGa&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
UPDATE wp2_posts &lt;br /&gt;
 SET `post_content`= replace(`post_content`, &amp;quot;&amp;#039; rel=&amp;#039;sexylightbox[]&amp;quot;, &amp;quot;&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Delete&lt;br /&gt;
&lt;br /&gt;
 Delete  FROM `master2011` WHERE id &amp;lt; 1688&lt;br /&gt;
 &lt;br /&gt;
Update single record&lt;br /&gt;
&lt;br /&gt;
 UPDATE Karaoke&lt;br /&gt;
 SET Title = &amp;#039;Size 10 Red Shoe&amp;#039;,&lt;br /&gt;
 Artists = &amp;#039;Big Red Shoes&lt;br /&gt;
 Where DiskId=1234&lt;br /&gt;
&lt;br /&gt;
This will grant all priviliges to the user admin. will only work on local host not remote&lt;br /&gt;
&lt;br /&gt;
 GRANT ALL ON *.* TO admin@localhost WITH GRANT OPTION;&lt;br /&gt;
&lt;br /&gt;
 FLUSH PRIVILEGES;  // this relloads the priviliges&lt;br /&gt;
&lt;br /&gt;
 use databasename // this loads the database&lt;br /&gt;
&lt;br /&gt;
 Show tables //show tables&lt;br /&gt;
&lt;br /&gt;
 Describe tablename//show fields&lt;br /&gt;
&lt;br /&gt;
 select * from tablename where Title Like &amp;quot;%fire%&amp;quot; //returns all instance of fire. you can also &lt;br /&gt;
&lt;br /&gt;
 select count (*) from tablename// returns number of records&lt;br /&gt;
&lt;br /&gt;
 select * from tablename where Diskid=&amp;quot;200&amp;quot;; // shows all records with disk id of 200&lt;br /&gt;
&lt;br /&gt;
 select diskid, track, title, artists from tablename order by title // display defined columns. sort by title&lt;br /&gt;
&lt;br /&gt;
 select artists, count(artists) from Karaoke Group by artists // counts the number of songs  by that artists&lt;br /&gt;
&lt;br /&gt;
 select artists, group_concat(title order by title separator &amp;#039; | &amp;#039; ) from tablename Group by artists // list them songs by artists&lt;br /&gt;
&lt;br /&gt;
 select * from passrequest where match (companyname, state) against (&amp;quot;texas&amp;quot;) //column has to be fulltext search- fulltext search is when you setup the     field proberties for the structure.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ALTER TABLE Karaoke AUTO_INCREMENT=15786 &lt;br /&gt;
Resets the auto_increment, in a situation where some of the most recently added rows were deleted. future insertions will be numbered from 15786 again (unless you still had rows numbered greater than 1234, and then the future insertions will start from the greatest number + 1 ).&lt;br /&gt;
&lt;br /&gt;
DELETE FROM tablename WHERE id=3; // will delete record with id 3&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Create mysql database in ubuntu shell==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
On a default settings, mysql root user do not need a password to authenticate from localhost. In this case, ou can login as root on your mysql server using:&lt;br /&gt;
&lt;br /&gt;
$ mysql -u root&lt;br /&gt;
&lt;br /&gt;
If a password is required, use the extra switch -p:&lt;br /&gt;
$ mysql -u root -p&lt;br /&gt;
Enter password:&lt;br /&gt;
&lt;br /&gt;
Now that you are logged in, we create a database:&lt;br /&gt;
mysql&amp;gt; create database amarokdb;&lt;br /&gt;
Query OK, 1 row affected (0.00 sec)&lt;br /&gt;
&lt;br /&gt;
We allow user amarokuser to connect to the server from localhost using the password amarokpasswd:&lt;br /&gt;
mysql&amp;gt; grant usage on *.* to amarokuser@localhost identified by &amp;#039;amarokpasswd&amp;#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.00 sec)&lt;br /&gt;
&lt;br /&gt;
And finally we grant all privileges on the amarok database to this user:&lt;br /&gt;
mysql&amp;gt; grant all privileges on amarokdb.* to amarokuser@localhost ;&lt;br /&gt;
Query OK, 0 rows affected (0.00 sec)&lt;br /&gt;
&lt;br /&gt;
And that&amp;#039;s it. You can now check that you can connect to the MySQL server using this command:&lt;br /&gt;
$ mysql -u amarokuser -p&amp;#039;amarokpasswd&amp;#039; amarokdb&lt;br /&gt;
Your MySQL connection id is 12&lt;br /&gt;
Server version: 5.0.38-Ubuntu_0ubuntu1-log Ubuntu 7.04 distribution&lt;br /&gt;
&lt;br /&gt;
Type &amp;#039;help;&amp;#039; or &amp;#039;\h&amp;#039; for help. Type &amp;#039;\c&amp;#039; to clear the buffer.&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
== securing MYSQL and setting a Password ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/usr/bin/mysql_secure_installation&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Set / Change Mysql Password ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Set / change / reset the MySQL root password on Ubuntu Linux. Enter the following lines in your terminal.&lt;br /&gt;
&lt;br /&gt;
Stop the MySQL Server.&lt;br /&gt;
sudo /etc/init.d/mysql stop&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
Start the mysqld configuration.&lt;br /&gt;
sudo mysqld --skip-grant-tables &amp;amp;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
Login to MySQL as root.&lt;br /&gt;
mysql -u root mysql&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
Replace YOURNEWPASSWORD with your new password!&lt;br /&gt;
UPDATE user SET Password=PASSWORD(&amp;#039;YOURNEWPASSWORD&amp;#039;) WHERE User=&amp;#039;root&amp;#039;; FLUSH PRIVILEGES; exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Reset mysql password  ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dpkg-reconfigure mysql-server-5.0&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
dpkg-reconfigure mysql-server-5.1&lt;br /&gt;
&lt;br /&gt;
Depending on which package you have installed.&lt;br /&gt;
&lt;br /&gt;
the will bring up the enter password screen for mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==  ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
[[#MySql Commands My Fav|Back To Top]]-[[Main_Page| Home]]&lt;br /&gt;
[[Category:Mysql]]&lt;/div&gt;</summary>
		<author><name>Bacchas</name></author>
	</entry>
	<entry>
		<id>https://www.r512.com/index.php?title=MYSQL_DATABASE_BACKUP&amp;diff=2899</id>
		<title>MYSQL DATABASE BACKUP</title>
		<link rel="alternate" type="text/html" href="https://www.r512.com/index.php?title=MYSQL_DATABASE_BACKUP&amp;diff=2899"/>
		<updated>2025-10-07T14:26:04Z</updated>

		<summary type="html">&lt;p&gt;Bacchas: Created page with &amp;quot;==Mysql Backup and Restore  == ===List Databases=== &amp;#039;&amp;#039;&amp;#039;Login to server &amp;#039;&amp;#039;&amp;#039;  mysql  &amp;#039;&amp;#039;&amp;#039; List databases&amp;#039;&amp;#039;&amp;#039;  show databases;  &amp;#039;&amp;#039;&amp;#039;List Tables in a database&amp;#039;&amp;#039;&amp;#039;  use databasename  show tables;  ===Bakcup a single database===  &amp;lt;pre&amp;gt; done from bash - no need to log in to mysql mysqldump -u root -ppassword sugarcrm &amp;gt; sugarcrm.sq  syntax  mysqldump -u root -p[root_password] [database_name] &amp;gt; dumpfilename.sql &amp;lt;/pre&amp;gt; ===Backup a single table=== &amp;lt;pre&amp;gt; mysqldump -u root -ppassword dat...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Mysql Backup and Restore  ==&lt;br /&gt;
===List Databases===&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Login to server &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 mysql&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; List databases&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 show databases;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;List Tables in a database&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 use databasename&lt;br /&gt;
 show tables;&lt;br /&gt;
&lt;br /&gt;
===Bakcup a single database===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
done from bash - no need to log in to mysql&lt;br /&gt;
mysqldump -u root -ppassword sugarcrm &amp;gt; sugarcrm.sq&lt;br /&gt;
&lt;br /&gt;
syntax&lt;br /&gt;
&lt;br /&gt;
mysqldump -u root -p[root_password] [database_name] &amp;gt; dumpfilename.sql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
===Backup a single table===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mysqldump -u root -ppassword databasename table &amp;gt; sugarcrm.sq&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
===Backup Multiple Database===&lt;br /&gt;
* log into mysql&lt;br /&gt;
&lt;br /&gt;
 mysql -u root -pyourpassword&lt;br /&gt;
 mysql&amp;gt; show databases;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;this will give you a list of databases&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;For example, if you want to take backup of both sugarcrm and bugs database, execute the mysqldump as shown below:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
 mysqldump -u root -ptmppassword --databases bugs sugarcrm &amp;gt; bugs_sugarcrm.sql&lt;br /&gt;
&lt;br /&gt;
* Verify the bugs_sugarcrm.sql dumpfile contains both the database backup.&lt;br /&gt;
&lt;br /&gt;
 # grep -i &amp;quot;Current database:&amp;quot; /tmp/bugs_sugarcrm.sql&lt;br /&gt;
&lt;br /&gt;
 -- Current Database: `mysql`&lt;br /&gt;
&lt;br /&gt;
 -- Current Database: `sugarcrm`&lt;br /&gt;
&lt;br /&gt;
=== Backup all the databases:===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
The following example takes a backup of  all the database of the MySQL instance.&lt;br /&gt;
&lt;br /&gt;
# mysqldump -u root -ptmppassword --all-databases &amp;gt; /tmp/all-database.sql&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
=== Backup a specific table:===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
In this example, we backup only the accounts_contacts table from sugarcrm database.&lt;br /&gt;
&lt;br /&gt;
mysqldump -u root -ptmppassword sugarcrm accounts_contacts &amp;gt; /tmp/sugarcrm_accounts_contacts.sql &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
[[#MySql Commands My Fav|Back To Top]]-[[Main_Page| Home]]&lt;br /&gt;
[[Category:Mysql]]&lt;/div&gt;</summary>
		<author><name>Bacchas</name></author>
	</entry>
	<entry>
		<id>https://www.r512.com/index.php?title=Mysql&amp;diff=2898</id>
		<title>Mysql</title>
		<link rel="alternate" type="text/html" href="https://www.r512.com/index.php?title=Mysql&amp;diff=2898"/>
		<updated>2025-10-07T14:24:50Z</updated>

		<summary type="html">&lt;p&gt;Bacchas: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=[[DADABIK]]=&lt;br /&gt;
=[[MYSQL COMMANDS]]=&lt;br /&gt;
=[[MYSQL DATABASE RESTORE]]=&lt;br /&gt;
=[[MYSQL DATABASE BACKUP]]=&lt;/div&gt;</summary>
		<author><name>Bacchas</name></author>
	</entry>
	<entry>
		<id>https://www.r512.com/index.php?title=MediaWiki:Sidebar&amp;diff=2897</id>
		<title>MediaWiki:Sidebar</title>
		<link rel="alternate" type="text/html" href="https://www.r512.com/index.php?title=MediaWiki:Sidebar&amp;diff=2897"/>
		<updated>2025-10-07T14:24:15Z</updated>

		<summary type="html">&lt;p&gt;Bacchas: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
* navigation&lt;br /&gt;
** mainpage|mainpage-description&lt;br /&gt;
** recentchanges-url|recentchanges&lt;br /&gt;
** randompage-url|randompage&lt;br /&gt;
** helppage|help&lt;br /&gt;
** MediaWiki:Sidebar|Edit Sidebar&lt;br /&gt;
** Special:Categories|List Categories&lt;br /&gt;
* SEARCH&lt;br /&gt;
* TOOLBOX&lt;br /&gt;
* LANGUAGES&lt;br /&gt;
*LINKS&lt;br /&gt;
**Programming|Programming&lt;br /&gt;
**Open Source Software|Open Source Software&lt;br /&gt;
**Python|Python&lt;br /&gt;
**Linode|Linode&lt;br /&gt;
**Mysql|Mysql&lt;br /&gt;
**Virtualization|Virtualization&lt;br /&gt;
**APPSHEET|APPSHEET&lt;br /&gt;
**Bash|Bash&lt;br /&gt;
**PowerShell|PowerShell&lt;br /&gt;
**Ansible|Ansible&lt;br /&gt;
*MORE LINKS&lt;br /&gt;
**MORE|MORE&lt;/div&gt;</summary>
		<author><name>Bacchas</name></author>
	</entry>
	<entry>
		<id>https://www.r512.com/index.php?title=MediaWiki:Sidebar&amp;diff=2896</id>
		<title>MediaWiki:Sidebar</title>
		<link rel="alternate" type="text/html" href="https://www.r512.com/index.php?title=MediaWiki:Sidebar&amp;diff=2896"/>
		<updated>2025-10-07T14:23:36Z</updated>

		<summary type="html">&lt;p&gt;Bacchas: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
* navigation&lt;br /&gt;
** mainpage|mainpage-description&lt;br /&gt;
** recentchanges-url|recentchanges&lt;br /&gt;
** randompage-url|randompage&lt;br /&gt;
** helppage|help&lt;br /&gt;
** MediaWiki:Sidebar|Edit Sidebar&lt;br /&gt;
** Special:Categories|List Categories&lt;br /&gt;
* SEARCH&lt;br /&gt;
* TOOLBOX&lt;br /&gt;
* LANGUAGES&lt;br /&gt;
*LINKS&lt;br /&gt;
**Programming|Programming&lt;br /&gt;
**Open Source Software|Open Source Software&lt;br /&gt;
**Python|Python&lt;br /&gt;
**Linode|Linode&lt;br /&gt;
**Mysql|Mysql&lt;br /&gt;
**Virtualization|Virtualization&lt;br /&gt;
**Vagrant|Vagrant&lt;br /&gt;
**Bash|Bash&lt;br /&gt;
**PowerShell|PowerShell&lt;br /&gt;
**Ansible|Ansible&lt;br /&gt;
*MORE LINKS&lt;br /&gt;
**MORE|MORE&lt;/div&gt;</summary>
		<author><name>Bacchas</name></author>
	</entry>
	<entry>
		<id>https://www.r512.com/index.php?title=MYSQL_COMMANDS&amp;diff=2895</id>
		<title>MYSQL COMMANDS</title>
		<link rel="alternate" type="text/html" href="https://www.r512.com/index.php?title=MYSQL_COMMANDS&amp;diff=2895"/>
		<updated>2025-10-07T14:20:41Z</updated>

		<summary type="html">&lt;p&gt;Bacchas: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==MySql Commands My Fav ==&lt;br /&gt;
&lt;br /&gt;
Find and Replace the word &amp;quot;GaGa, Ladyy&amp;quot; in Artists and replace with &amp;quot;Lady GaGa&lt;br /&gt;
&lt;br /&gt;
 UPDATE Karaoke set Artists = replace(Artists, &amp;quot;GaGa, Lady&amp;quot;, &amp;quot;Lady GaGa&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
UPDATE wp2_posts &lt;br /&gt;
 SET `post_content`= replace(`post_content`, &amp;quot;&amp;#039; rel=&amp;#039;sexylightbox[]&amp;quot;, &amp;quot;&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Delete&lt;br /&gt;
&lt;br /&gt;
 Delete  FROM `master2011` WHERE id &amp;lt; 1688&lt;br /&gt;
 &lt;br /&gt;
Update single record&lt;br /&gt;
&lt;br /&gt;
 UPDATE Karaoke&lt;br /&gt;
 SET Title = &amp;#039;Size 10 Red Shoe&amp;#039;,&lt;br /&gt;
 Artists = &amp;#039;Big Red Shoes&lt;br /&gt;
 Where DiskId=1234&lt;br /&gt;
&lt;br /&gt;
This will grant all priviliges to the user admin. will only work on local host not remote&lt;br /&gt;
&lt;br /&gt;
 GRANT ALL ON *.* TO admin@localhost WITH GRANT OPTION;&lt;br /&gt;
&lt;br /&gt;
 FLUSH PRIVILEGES;  // this relloads the priviliges&lt;br /&gt;
&lt;br /&gt;
 use databasename // this loads the database&lt;br /&gt;
&lt;br /&gt;
 Show tables //show tables&lt;br /&gt;
&lt;br /&gt;
 Describe tablename//show fields&lt;br /&gt;
&lt;br /&gt;
 select * from tablename where Title Like &amp;quot;%fire%&amp;quot; //returns all instance of fire. you can also &lt;br /&gt;
&lt;br /&gt;
 select count (*) from tablename// returns number of records&lt;br /&gt;
&lt;br /&gt;
 select * from tablename where Diskid=&amp;quot;200&amp;quot;; // shows all records with disk id of 200&lt;br /&gt;
&lt;br /&gt;
 select diskid, track, title, artists from tablename order by title // display defined columns. sort by title&lt;br /&gt;
&lt;br /&gt;
 select artists, count(artists) from Karaoke Group by artists // counts the number of songs  by that artists&lt;br /&gt;
&lt;br /&gt;
 select artists, group_concat(title order by title separator &amp;#039; | &amp;#039; ) from tablename Group by artists // list them songs by artists&lt;br /&gt;
&lt;br /&gt;
 select * from passrequest where match (companyname, state) against (&amp;quot;texas&amp;quot;) //column has to be fulltext search- fulltext search is when you setup the     field proberties for the structure.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ALTER TABLE Karaoke AUTO_INCREMENT=15786 &lt;br /&gt;
Resets the auto_increment, in a situation where some of the most recently added rows were deleted. future insertions will be numbered from 15786 again (unless you still had rows numbered greater than 1234, and then the future insertions will start from the greatest number + 1 ).&lt;br /&gt;
&lt;br /&gt;
DELETE FROM tablename WHERE id=3; // will delete record with id 3&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Create mysql database in ubuntu shell==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
On a default settings, mysql root user do not need a password to authenticate from localhost. In this case, ou can login as root on your mysql server using:&lt;br /&gt;
&lt;br /&gt;
$ mysql -u root&lt;br /&gt;
&lt;br /&gt;
If a password is required, use the extra switch -p:&lt;br /&gt;
$ mysql -u root -p&lt;br /&gt;
Enter password:&lt;br /&gt;
&lt;br /&gt;
Now that you are logged in, we create a database:&lt;br /&gt;
mysql&amp;gt; create database amarokdb;&lt;br /&gt;
Query OK, 1 row affected (0.00 sec)&lt;br /&gt;
&lt;br /&gt;
We allow user amarokuser to connect to the server from localhost using the password amarokpasswd:&lt;br /&gt;
mysql&amp;gt; grant usage on *.* to amarokuser@localhost identified by &amp;#039;amarokpasswd&amp;#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.00 sec)&lt;br /&gt;
&lt;br /&gt;
And finally we grant all privileges on the amarok database to this user:&lt;br /&gt;
mysql&amp;gt; grant all privileges on amarokdb.* to amarokuser@localhost ;&lt;br /&gt;
Query OK, 0 rows affected (0.00 sec)&lt;br /&gt;
&lt;br /&gt;
And that&amp;#039;s it. You can now check that you can connect to the MySQL server using this command:&lt;br /&gt;
$ mysql -u amarokuser -p&amp;#039;amarokpasswd&amp;#039; amarokdb&lt;br /&gt;
Your MySQL connection id is 12&lt;br /&gt;
Server version: 5.0.38-Ubuntu_0ubuntu1-log Ubuntu 7.04 distribution&lt;br /&gt;
&lt;br /&gt;
Type &amp;#039;help;&amp;#039; or &amp;#039;\h&amp;#039; for help. Type &amp;#039;\c&amp;#039; to clear the buffer.&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
== securing MYSQL and setting a Password ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/usr/bin/mysql_secure_installation&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Mysql Backup and Restore  ==&lt;br /&gt;
===List Databases===&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Login to server &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 mysql&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; List databases&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 show databases;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;List Tables in a database&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 use databasename&lt;br /&gt;
 show tables;&lt;br /&gt;
&lt;br /&gt;
===Bakcup a single database===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
done from bash - no need to log in to mysql&lt;br /&gt;
mysqldump -u root -ppassword sugarcrm &amp;gt; sugarcrm.sq&lt;br /&gt;
&lt;br /&gt;
syntax&lt;br /&gt;
&lt;br /&gt;
mysqldump -u root -p[root_password] [database_name] &amp;gt; dumpfilename.sql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
===Backup a single table===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mysqldump -u root -ppassword databasename table &amp;gt; sugarcrm.sq&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
===Backup Multiple Database===&lt;br /&gt;
* log into mysql&lt;br /&gt;
&lt;br /&gt;
 mysql -u root -pyourpassword&lt;br /&gt;
 mysql&amp;gt; show databases;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;this will give you a list of databases&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;For example, if you want to take backup of both sugarcrm and bugs database, execute the mysqldump as shown below:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
 mysqldump -u root -ptmppassword --databases bugs sugarcrm &amp;gt; bugs_sugarcrm.sql&lt;br /&gt;
&lt;br /&gt;
* Verify the bugs_sugarcrm.sql dumpfile contains both the database backup.&lt;br /&gt;
&lt;br /&gt;
 # grep -i &amp;quot;Current database:&amp;quot; /tmp/bugs_sugarcrm.sql&lt;br /&gt;
&lt;br /&gt;
 -- Current Database: `mysql`&lt;br /&gt;
&lt;br /&gt;
 -- Current Database: `sugarcrm`&lt;br /&gt;
&lt;br /&gt;
=== Backup all the databases:===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
The following example takes a backup of  all the database of the MySQL instance.&lt;br /&gt;
&lt;br /&gt;
# mysqldump -u root -ptmppassword --all-databases &amp;gt; /tmp/all-database.sql&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
=== Backup a specific table:===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
In this example, we backup only the accounts_contacts table from sugarcrm database.&lt;br /&gt;
&lt;br /&gt;
mysqldump -u root -ptmppassword sugarcrm accounts_contacts &amp;gt; /tmp/sugarcrm_accounts_contacts.sql &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Set / Change Mysql Password ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Set / change / reset the MySQL root password on Ubuntu Linux. Enter the following lines in your terminal.&lt;br /&gt;
&lt;br /&gt;
Stop the MySQL Server.&lt;br /&gt;
sudo /etc/init.d/mysql stop&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
Start the mysqld configuration.&lt;br /&gt;
sudo mysqld --skip-grant-tables &amp;amp;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
Login to MySQL as root.&lt;br /&gt;
mysql -u root mysql&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
Replace YOURNEWPASSWORD with your new password!&lt;br /&gt;
UPDATE user SET Password=PASSWORD(&amp;#039;YOURNEWPASSWORD&amp;#039;) WHERE User=&amp;#039;root&amp;#039;; FLUSH PRIVILEGES; exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Reset mysql password  ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dpkg-reconfigure mysql-server-5.0&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
dpkg-reconfigure mysql-server-5.1&lt;br /&gt;
&lt;br /&gt;
Depending on which package you have installed.&lt;br /&gt;
&lt;br /&gt;
the will bring up the enter password screen for mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==  ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
[[#MySql Commands My Fav|Back To Top]]-[[Main_Page| Home]]&lt;br /&gt;
[[Category:Mysql]]&lt;/div&gt;</summary>
		<author><name>Bacchas</name></author>
	</entry>
	<entry>
		<id>https://www.r512.com/index.php?title=MYSQL_DATABASE_RESTORE&amp;diff=2894</id>
		<title>MYSQL DATABASE RESTORE</title>
		<link rel="alternate" type="text/html" href="https://www.r512.com/index.php?title=MYSQL_DATABASE_RESTORE&amp;diff=2894"/>
		<updated>2025-10-07T14:19:17Z</updated>

		<summary type="html">&lt;p&gt;Bacchas: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Restore Database==&lt;br /&gt;
&amp;lt;p style=&amp;quot;background-color: #77a8f7; font-weight: bold; font-size: 1.2rem;&amp;quot;&amp;gt; I used this to restore r512 from the dumped .sql file in 2025 &amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p style=&amp;quot;font-weight: bold;font-size: 1.3rem&amp;quot;&amp;gt; I tried to restore it using phpmyadmin, but it did not work, got many errors. probably because it was a raw sql dump backup. The target database must already exist. if it doesn&amp;#039;t, create it first&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* log into mysql&lt;br /&gt;
 CREATE DATABASE your_database_name;&lt;br /&gt;
&lt;br /&gt;
 mysql&lt;br /&gt;
 use databasename;&lt;br /&gt;
&lt;br /&gt;
 SOURCE /path/to/file/file.sql;&lt;br /&gt;
&amp;lt;hr /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;h4 class=&amp;quot;yellowbackground&amp;quot;&amp;gt;Script to import a CSV File into an existing Database&amp;lt;/h4&amp;gt; ==&lt;br /&gt;
&amp;lt;p style=&amp;quot;background-color: #77a8f7; font-weight: bold; font-size: 1.2rem;&amp;quot;&amp;gt;The csv file has to be in a specific directory. /var/lib/mysql-files/&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p style=&amp;quot;background-color: #77a8f7; font-weight: bold; font-size: 1.2rem;&amp;quot;&amp;gt;The table has to already exist &amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
mysql kartest &amp;lt;&amp;lt;EOF&lt;br /&gt;
truncate table songs;&lt;br /&gt;
load data infile &amp;#039;/var/lib/mysql-files/songs.csv&amp;#039;&lt;br /&gt;
into table songs&lt;br /&gt;
fields terminated by &amp;#039;|&amp;#039;&lt;br /&gt;
enclosed by &amp;#039;&amp;quot;&amp;#039;&lt;br /&gt;
lines terminated by &amp;#039;\n&amp;#039;&lt;br /&gt;
ignore 1 rows;&lt;br /&gt;
EOF&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Copy csv file to a dir and run script on server ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
fxcopy=&amp;quot;/mnt/c/Users/john/Dropbox/Shining Cabinet/My Stuff/sqlitedb&amp;quot;&lt;br /&gt;
scp -i ~/.ssh/linode &amp;quot;$fxcopy/filename.csv&amp;quot; 1.1.1.1:/var/lib/mysql-files/&lt;br /&gt;
sleep 4&lt;br /&gt;
ssh -i ~/.ssh/linode root@1.1.1.1 /var/www/scripts/import.sh&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Fixing error connecting to database from AppSheet ==&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; The permission has to be fixed to the old version in mysql server &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
 ALTER USER &amp;#039;username&amp;#039;@&amp;#039;%&amp;#039; IDENTIFIED WITH mysql_native_password BY &amp;#039;password&amp;#039;;&lt;br /&gt;
 FLUSH PRIVILEGES;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
[[#MySql Commands My Fav|Back To Top]]-[[Main_Page| Home]]&lt;br /&gt;
[[Category:Mysql]]&lt;/div&gt;</summary>
		<author><name>Bacchas</name></author>
	</entry>
	<entry>
		<id>https://www.r512.com/index.php?title=MYSQL_DATABASE_RESTORE&amp;diff=2893</id>
		<title>MYSQL DATABASE RESTORE</title>
		<link rel="alternate" type="text/html" href="https://www.r512.com/index.php?title=MYSQL_DATABASE_RESTORE&amp;diff=2893"/>
		<updated>2025-10-07T14:17:50Z</updated>

		<summary type="html">&lt;p&gt;Bacchas: Created page with &amp;quot;==Restore Database== &amp;lt;p style=&amp;quot;background-color: #77a8f7; font-weight: bold; font-size: 1.2rem;&amp;quot;&amp;gt; I used this to restore r512 from the dumped .sql file in 2025 &amp;lt;/p&amp;gt; &amp;lt;p style=&amp;quot;font-weight: bold;font-size: 1.3rem&amp;quot;&amp;gt; I tried to restore it using phpmyadmin, but it did not work, got many errors. probably because it was a raw sql dump backup. The target database must already exist. if it doesn&amp;#039;t, create it first&amp;lt;/p&amp;gt;   * log into mysql  CREATE DATABASE your_database_name;   mysq...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Restore Database==&lt;br /&gt;
&amp;lt;p style=&amp;quot;background-color: #77a8f7; font-weight: bold; font-size: 1.2rem;&amp;quot;&amp;gt; I used this to restore r512 from the dumped .sql file in 2025 &amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p style=&amp;quot;font-weight: bold;font-size: 1.3rem&amp;quot;&amp;gt; I tried to restore it using phpmyadmin, but it did not work, got many errors. probably because it was a raw sql dump backup. The target database must already exist. if it doesn&amp;#039;t, create it first&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* log into mysql&lt;br /&gt;
 CREATE DATABASE your_database_name;&lt;br /&gt;
&lt;br /&gt;
 mysql&lt;br /&gt;
 use databasename;&lt;br /&gt;
&lt;br /&gt;
 SOURCE /path/to/file/file.sql;&lt;br /&gt;
&amp;lt;hr /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;h4 class=&amp;quot;yellowbackground&amp;quot;&amp;gt;Script to import a CSV File into an existing Database&amp;lt;/h4&amp;gt; ==&lt;br /&gt;
&amp;lt;p style=&amp;quot;background-color: #77a8f7; font-weight: bold; font-size: 1.2rem;&amp;quot;&amp;gt;The csv file has to be in a specific directory. /var/lib/mysql-files/&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p style=&amp;quot;background-color: #77a8f7; font-weight: bold; font-size: 1.2rem;&amp;quot;&amp;gt;The table has to already exist &amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
mysql kartest &amp;lt;&amp;lt;EOF&lt;br /&gt;
truncate table songs;&lt;br /&gt;
load data infile &amp;#039;/var/lib/mysql-files/songs.csv&amp;#039;&lt;br /&gt;
into table songs&lt;br /&gt;
fields terminated by &amp;#039;|&amp;#039;&lt;br /&gt;
enclosed by &amp;#039;&amp;quot;&amp;#039;&lt;br /&gt;
lines terminated by &amp;#039;\n&amp;#039;&lt;br /&gt;
ignore 1 rows;&lt;br /&gt;
EOF&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Copy csv file to a dir and run script on server ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
fxcopy=&amp;quot;/mnt/c/Users/john/Dropbox/Shining Cabinet/My Stuff/sqlitedb&amp;quot;&lt;br /&gt;
scp -i ~/.ssh/linode &amp;quot;$fxcopy/filename.csv&amp;quot; 1.1.1.1:/var/lib/mysql-files/&lt;br /&gt;
sleep 4&lt;br /&gt;
ssh -i ~/.ssh/linode root@1.1.1.1 /var/www/scripts/import.sh&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Fixing error connecting to database from AppSheet ==&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; The permission has to be fixed to the old version in mysql server &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
 ALTER USER &amp;#039;username&amp;#039;@&amp;#039;%&amp;#039; IDENTIFIED WITH mysql_native_password BY &amp;#039;password&amp;#039;;&lt;br /&gt;
 FLUSH PRIVILEGES;&lt;/div&gt;</summary>
		<author><name>Bacchas</name></author>
	</entry>
	<entry>
		<id>https://www.r512.com/index.php?title=Mysql&amp;diff=2892</id>
		<title>Mysql</title>
		<link rel="alternate" type="text/html" href="https://www.r512.com/index.php?title=Mysql&amp;diff=2892"/>
		<updated>2025-10-07T14:14:56Z</updated>

		<summary type="html">&lt;p&gt;Bacchas: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=[[DADABIK]]=&lt;br /&gt;
=[[MYSQL COMMANDS]]=&lt;br /&gt;
=[[MYSQL DATABASE RESTORE]]=&lt;/div&gt;</summary>
		<author><name>Bacchas</name></author>
	</entry>
	<entry>
		<id>https://www.r512.com/index.php?title=MYSQL_COMMANDS&amp;diff=2891</id>
		<title>MYSQL COMMANDS</title>
		<link rel="alternate" type="text/html" href="https://www.r512.com/index.php?title=MYSQL_COMMANDS&amp;diff=2891"/>
		<updated>2025-10-06T16:15:04Z</updated>

		<summary type="html">&lt;p&gt;Bacchas: /* Restore Database */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==MySql Commands My Fav ==&lt;br /&gt;
&lt;br /&gt;
Find and Replace the word &amp;quot;GaGa, Ladyy&amp;quot; in Artists and replace with &amp;quot;Lady GaGa&lt;br /&gt;
&lt;br /&gt;
 UPDATE Karaoke set Artists = replace(Artists, &amp;quot;GaGa, Lady&amp;quot;, &amp;quot;Lady GaGa&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
UPDATE wp2_posts &lt;br /&gt;
 SET `post_content`= replace(`post_content`, &amp;quot;&amp;#039; rel=&amp;#039;sexylightbox[]&amp;quot;, &amp;quot;&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Delete&lt;br /&gt;
&lt;br /&gt;
 Delete  FROM `master2011` WHERE id &amp;lt; 1688&lt;br /&gt;
 &lt;br /&gt;
Update single record&lt;br /&gt;
&lt;br /&gt;
 UPDATE Karaoke&lt;br /&gt;
 SET Title = &amp;#039;Size 10 Red Shoe&amp;#039;,&lt;br /&gt;
 Artists = &amp;#039;Big Red Shoes&lt;br /&gt;
 Where DiskId=1234&lt;br /&gt;
&lt;br /&gt;
This will grant all priviliges to the user admin. will only work on local host not remote&lt;br /&gt;
&lt;br /&gt;
 GRANT ALL ON *.* TO admin@localhost WITH GRANT OPTION;&lt;br /&gt;
&lt;br /&gt;
 FLUSH PRIVILEGES;  // this relloads the priviliges&lt;br /&gt;
&lt;br /&gt;
 use databasename // this loads the database&lt;br /&gt;
&lt;br /&gt;
 Show tables //show tables&lt;br /&gt;
&lt;br /&gt;
 Describe tablename//show fields&lt;br /&gt;
&lt;br /&gt;
 select * from tablename where Title Like &amp;quot;%fire%&amp;quot; //returns all instance of fire. you can also &lt;br /&gt;
&lt;br /&gt;
 select count (*) from tablename// returns number of records&lt;br /&gt;
&lt;br /&gt;
 select * from tablename where Diskid=&amp;quot;200&amp;quot;; // shows all records with disk id of 200&lt;br /&gt;
&lt;br /&gt;
 select diskid, track, title, artists from tablename order by title // display defined columns. sort by title&lt;br /&gt;
&lt;br /&gt;
 select artists, count(artists) from Karaoke Group by artists // counts the number of songs  by that artists&lt;br /&gt;
&lt;br /&gt;
 select artists, group_concat(title order by title separator &amp;#039; | &amp;#039; ) from tablename Group by artists // list them songs by artists&lt;br /&gt;
&lt;br /&gt;
 select * from passrequest where match (companyname, state) against (&amp;quot;texas&amp;quot;) //column has to be fulltext search- fulltext search is when you setup the     field proberties for the structure.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ALTER TABLE Karaoke AUTO_INCREMENT=15786 &lt;br /&gt;
Resets the auto_increment, in a situation where some of the most recently added rows were deleted. future insertions will be numbered from 15786 again (unless you still had rows numbered greater than 1234, and then the future insertions will start from the greatest number + 1 ).&lt;br /&gt;
&lt;br /&gt;
DELETE FROM tablename WHERE id=3; // will delete record with id 3&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Create mysql database in ubuntu shell==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
On a default settings, mysql root user do not need a password to authenticate from localhost. In this case, ou can login as root on your mysql server using:&lt;br /&gt;
&lt;br /&gt;
$ mysql -u root&lt;br /&gt;
&lt;br /&gt;
If a password is required, use the extra switch -p:&lt;br /&gt;
$ mysql -u root -p&lt;br /&gt;
Enter password:&lt;br /&gt;
&lt;br /&gt;
Now that you are logged in, we create a database:&lt;br /&gt;
mysql&amp;gt; create database amarokdb;&lt;br /&gt;
Query OK, 1 row affected (0.00 sec)&lt;br /&gt;
&lt;br /&gt;
We allow user amarokuser to connect to the server from localhost using the password amarokpasswd:&lt;br /&gt;
mysql&amp;gt; grant usage on *.* to amarokuser@localhost identified by &amp;#039;amarokpasswd&amp;#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.00 sec)&lt;br /&gt;
&lt;br /&gt;
And finally we grant all privileges on the amarok database to this user:&lt;br /&gt;
mysql&amp;gt; grant all privileges on amarokdb.* to amarokuser@localhost ;&lt;br /&gt;
Query OK, 0 rows affected (0.00 sec)&lt;br /&gt;
&lt;br /&gt;
And that&amp;#039;s it. You can now check that you can connect to the MySQL server using this command:&lt;br /&gt;
$ mysql -u amarokuser -p&amp;#039;amarokpasswd&amp;#039; amarokdb&lt;br /&gt;
Your MySQL connection id is 12&lt;br /&gt;
Server version: 5.0.38-Ubuntu_0ubuntu1-log Ubuntu 7.04 distribution&lt;br /&gt;
&lt;br /&gt;
Type &amp;#039;help;&amp;#039; or &amp;#039;\h&amp;#039; for help. Type &amp;#039;\c&amp;#039; to clear the buffer.&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
== securing MYSQL and setting a Password ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/usr/bin/mysql_secure_installation&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Mysql Backup and Restore  ==&lt;br /&gt;
===List Databases===&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Login to server &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 mysql&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; List databases&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 show databases;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;List Tables in a database&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 use databasename&lt;br /&gt;
 show tables;&lt;br /&gt;
&lt;br /&gt;
===Bakcup a single database===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
done from bash - no need to log in to mysql&lt;br /&gt;
mysqldump -u root -ppassword sugarcrm &amp;gt; sugarcrm.sq&lt;br /&gt;
&lt;br /&gt;
syntax&lt;br /&gt;
&lt;br /&gt;
mysqldump -u root -p[root_password] [database_name] &amp;gt; dumpfilename.sql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
===Backup a single table===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mysqldump -u root -ppassword databasename table &amp;gt; sugarcrm.sq&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
===Backup Multiple Database===&lt;br /&gt;
* log into mysql&lt;br /&gt;
&lt;br /&gt;
 mysql -u root -pyourpassword&lt;br /&gt;
 mysql&amp;gt; show databases;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;this will give you a list of databases&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;For example, if you want to take backup of both sugarcrm and bugs database, execute the mysqldump as shown below:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
 mysqldump -u root -ptmppassword --databases bugs sugarcrm &amp;gt; bugs_sugarcrm.sql&lt;br /&gt;
&lt;br /&gt;
* Verify the bugs_sugarcrm.sql dumpfile contains both the database backup.&lt;br /&gt;
&lt;br /&gt;
 # grep -i &amp;quot;Current database:&amp;quot; /tmp/bugs_sugarcrm.sql&lt;br /&gt;
&lt;br /&gt;
 -- Current Database: `mysql`&lt;br /&gt;
&lt;br /&gt;
 -- Current Database: `sugarcrm`&lt;br /&gt;
&lt;br /&gt;
=== Backup all the databases:===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
The following example takes a backup of  all the database of the MySQL instance.&lt;br /&gt;
&lt;br /&gt;
# mysqldump -u root -ptmppassword --all-databases &amp;gt; /tmp/all-database.sql&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
=== Backup a specific table:===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
In this example, we backup only the accounts_contacts table from sugarcrm database.&lt;br /&gt;
&lt;br /&gt;
mysqldump -u root -ptmppassword sugarcrm accounts_contacts &amp;gt; /tmp/sugarcrm_accounts_contacts.sql &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;h4 class=&amp;quot;yellowbackground&amp;quot;&amp;gt;Script to import a CSV File into an existing Database&amp;lt;/h4&amp;gt; ==&lt;br /&gt;
&amp;lt;p style=&amp;quot;background-color: #77a8f7; font-weight: bold; font-size: 1.2rem;&amp;quot;&amp;gt;The csv file has to be in a specific directory. /var/lib/mysql-files/&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p style=&amp;quot;background-color: #77a8f7; font-weight: bold; font-size: 1.2rem;&amp;quot;&amp;gt;The table has to already exist &amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
mysql kartest &amp;lt;&amp;lt;EOF&lt;br /&gt;
truncate table songs;&lt;br /&gt;
load data infile &amp;#039;/var/lib/mysql-files/songs.csv&amp;#039;&lt;br /&gt;
into table songs&lt;br /&gt;
fields terminated by &amp;#039;|&amp;#039;&lt;br /&gt;
enclosed by &amp;#039;&amp;quot;&amp;#039;&lt;br /&gt;
lines terminated by &amp;#039;\n&amp;#039;&lt;br /&gt;
ignore 1 rows;&lt;br /&gt;
EOF&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Copy csv file to a dir and run script on server ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
fxcopy=&amp;quot;/mnt/c/Users/john/Dropbox/Shining Cabinet/My Stuff/sqlitedb&amp;quot;&lt;br /&gt;
scp -i ~/.ssh/linode &amp;quot;$fxcopy/filename.csv&amp;quot; 1.1.1.1:/var/lib/mysql-files/&lt;br /&gt;
sleep 4&lt;br /&gt;
ssh -i ~/.ssh/linode root@1.1.1.1 /var/www/scripts/import.sh&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Fixing error connecting to database from AppSheet ==&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; The permission has to be fixed to the old version in mysql server &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
 ALTER USER &amp;#039;username&amp;#039;@&amp;#039;%&amp;#039; IDENTIFIED WITH mysql_native_password BY &amp;#039;password&amp;#039;;&lt;br /&gt;
 FLUSH PRIVILEGES;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Restore Database==&lt;br /&gt;
&amp;lt;p style=&amp;quot;background-color: #77a8f7; font-weight: bold; font-size: 1.2rem;&amp;quot;&amp;gt; I used this to restore r512 from the dumped .sql file in 2025 &amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p style=&amp;quot;font-weight: bold;font-size: 1.3rem&amp;quot;&amp;gt; I tried to restore it using phpmyadmin, but it did not work, got many errors. probably because it was a raw sql dump backup. The target database must already exist. if it doesn&amp;#039;t, create it first&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* log into mysql&lt;br /&gt;
 CREATE DATABASE your_database_name;&lt;br /&gt;
&lt;br /&gt;
 mysql&lt;br /&gt;
 use databasename;&lt;br /&gt;
&lt;br /&gt;
 SOURCE /path/to/file/file.sql;&lt;br /&gt;
&lt;br /&gt;
== Set / Change Mysql Password ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Set / change / reset the MySQL root password on Ubuntu Linux. Enter the following lines in your terminal.&lt;br /&gt;
&lt;br /&gt;
Stop the MySQL Server.&lt;br /&gt;
sudo /etc/init.d/mysql stop&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
Start the mysqld configuration.&lt;br /&gt;
sudo mysqld --skip-grant-tables &amp;amp;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
Login to MySQL as root.&lt;br /&gt;
mysql -u root mysql&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
Replace YOURNEWPASSWORD with your new password!&lt;br /&gt;
UPDATE user SET Password=PASSWORD(&amp;#039;YOURNEWPASSWORD&amp;#039;) WHERE User=&amp;#039;root&amp;#039;; FLUSH PRIVILEGES; exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Reset mysql password  ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dpkg-reconfigure mysql-server-5.0&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
dpkg-reconfigure mysql-server-5.1&lt;br /&gt;
&lt;br /&gt;
Depending on which package you have installed.&lt;br /&gt;
&lt;br /&gt;
the will bring up the enter password screen for mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==  ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
[[#MySql Commands My Fav|Back To Top]]-[[Main_Page| Home]]&lt;br /&gt;
[[Category:Mysql]]&lt;/div&gt;</summary>
		<author><name>Bacchas</name></author>
	</entry>
	<entry>
		<id>https://www.r512.com/index.php?title=MYSQL_COMMANDS&amp;diff=2890</id>
		<title>MYSQL COMMANDS</title>
		<link rel="alternate" type="text/html" href="https://www.r512.com/index.php?title=MYSQL_COMMANDS&amp;diff=2890"/>
		<updated>2025-10-06T16:03:38Z</updated>

		<summary type="html">&lt;p&gt;Bacchas: /* Restore Database */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==MySql Commands My Fav ==&lt;br /&gt;
&lt;br /&gt;
Find and Replace the word &amp;quot;GaGa, Ladyy&amp;quot; in Artists and replace with &amp;quot;Lady GaGa&lt;br /&gt;
&lt;br /&gt;
 UPDATE Karaoke set Artists = replace(Artists, &amp;quot;GaGa, Lady&amp;quot;, &amp;quot;Lady GaGa&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
UPDATE wp2_posts &lt;br /&gt;
 SET `post_content`= replace(`post_content`, &amp;quot;&amp;#039; rel=&amp;#039;sexylightbox[]&amp;quot;, &amp;quot;&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Delete&lt;br /&gt;
&lt;br /&gt;
 Delete  FROM `master2011` WHERE id &amp;lt; 1688&lt;br /&gt;
 &lt;br /&gt;
Update single record&lt;br /&gt;
&lt;br /&gt;
 UPDATE Karaoke&lt;br /&gt;
 SET Title = &amp;#039;Size 10 Red Shoe&amp;#039;,&lt;br /&gt;
 Artists = &amp;#039;Big Red Shoes&lt;br /&gt;
 Where DiskId=1234&lt;br /&gt;
&lt;br /&gt;
This will grant all priviliges to the user admin. will only work on local host not remote&lt;br /&gt;
&lt;br /&gt;
 GRANT ALL ON *.* TO admin@localhost WITH GRANT OPTION;&lt;br /&gt;
&lt;br /&gt;
 FLUSH PRIVILEGES;  // this relloads the priviliges&lt;br /&gt;
&lt;br /&gt;
 use databasename // this loads the database&lt;br /&gt;
&lt;br /&gt;
 Show tables //show tables&lt;br /&gt;
&lt;br /&gt;
 Describe tablename//show fields&lt;br /&gt;
&lt;br /&gt;
 select * from tablename where Title Like &amp;quot;%fire%&amp;quot; //returns all instance of fire. you can also &lt;br /&gt;
&lt;br /&gt;
 select count (*) from tablename// returns number of records&lt;br /&gt;
&lt;br /&gt;
 select * from tablename where Diskid=&amp;quot;200&amp;quot;; // shows all records with disk id of 200&lt;br /&gt;
&lt;br /&gt;
 select diskid, track, title, artists from tablename order by title // display defined columns. sort by title&lt;br /&gt;
&lt;br /&gt;
 select artists, count(artists) from Karaoke Group by artists // counts the number of songs  by that artists&lt;br /&gt;
&lt;br /&gt;
 select artists, group_concat(title order by title separator &amp;#039; | &amp;#039; ) from tablename Group by artists // list them songs by artists&lt;br /&gt;
&lt;br /&gt;
 select * from passrequest where match (companyname, state) against (&amp;quot;texas&amp;quot;) //column has to be fulltext search- fulltext search is when you setup the     field proberties for the structure.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ALTER TABLE Karaoke AUTO_INCREMENT=15786 &lt;br /&gt;
Resets the auto_increment, in a situation where some of the most recently added rows were deleted. future insertions will be numbered from 15786 again (unless you still had rows numbered greater than 1234, and then the future insertions will start from the greatest number + 1 ).&lt;br /&gt;
&lt;br /&gt;
DELETE FROM tablename WHERE id=3; // will delete record with id 3&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Create mysql database in ubuntu shell==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
On a default settings, mysql root user do not need a password to authenticate from localhost. In this case, ou can login as root on your mysql server using:&lt;br /&gt;
&lt;br /&gt;
$ mysql -u root&lt;br /&gt;
&lt;br /&gt;
If a password is required, use the extra switch -p:&lt;br /&gt;
$ mysql -u root -p&lt;br /&gt;
Enter password:&lt;br /&gt;
&lt;br /&gt;
Now that you are logged in, we create a database:&lt;br /&gt;
mysql&amp;gt; create database amarokdb;&lt;br /&gt;
Query OK, 1 row affected (0.00 sec)&lt;br /&gt;
&lt;br /&gt;
We allow user amarokuser to connect to the server from localhost using the password amarokpasswd:&lt;br /&gt;
mysql&amp;gt; grant usage on *.* to amarokuser@localhost identified by &amp;#039;amarokpasswd&amp;#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.00 sec)&lt;br /&gt;
&lt;br /&gt;
And finally we grant all privileges on the amarok database to this user:&lt;br /&gt;
mysql&amp;gt; grant all privileges on amarokdb.* to amarokuser@localhost ;&lt;br /&gt;
Query OK, 0 rows affected (0.00 sec)&lt;br /&gt;
&lt;br /&gt;
And that&amp;#039;s it. You can now check that you can connect to the MySQL server using this command:&lt;br /&gt;
$ mysql -u amarokuser -p&amp;#039;amarokpasswd&amp;#039; amarokdb&lt;br /&gt;
Your MySQL connection id is 12&lt;br /&gt;
Server version: 5.0.38-Ubuntu_0ubuntu1-log Ubuntu 7.04 distribution&lt;br /&gt;
&lt;br /&gt;
Type &amp;#039;help;&amp;#039; or &amp;#039;\h&amp;#039; for help. Type &amp;#039;\c&amp;#039; to clear the buffer.&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
== securing MYSQL and setting a Password ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/usr/bin/mysql_secure_installation&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Mysql Backup and Restore  ==&lt;br /&gt;
===List Databases===&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Login to server &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 mysql&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; List databases&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 show databases;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;List Tables in a database&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 use databasename&lt;br /&gt;
 show tables;&lt;br /&gt;
&lt;br /&gt;
===Bakcup a single database===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
done from bash - no need to log in to mysql&lt;br /&gt;
mysqldump -u root -ppassword sugarcrm &amp;gt; sugarcrm.sq&lt;br /&gt;
&lt;br /&gt;
syntax&lt;br /&gt;
&lt;br /&gt;
mysqldump -u root -p[root_password] [database_name] &amp;gt; dumpfilename.sql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
===Backup a single table===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mysqldump -u root -ppassword databasename table &amp;gt; sugarcrm.sq&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
===Backup Multiple Database===&lt;br /&gt;
* log into mysql&lt;br /&gt;
&lt;br /&gt;
 mysql -u root -pyourpassword&lt;br /&gt;
 mysql&amp;gt; show databases;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;this will give you a list of databases&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;For example, if you want to take backup of both sugarcrm and bugs database, execute the mysqldump as shown below:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
 mysqldump -u root -ptmppassword --databases bugs sugarcrm &amp;gt; bugs_sugarcrm.sql&lt;br /&gt;
&lt;br /&gt;
* Verify the bugs_sugarcrm.sql dumpfile contains both the database backup.&lt;br /&gt;
&lt;br /&gt;
 # grep -i &amp;quot;Current database:&amp;quot; /tmp/bugs_sugarcrm.sql&lt;br /&gt;
&lt;br /&gt;
 -- Current Database: `mysql`&lt;br /&gt;
&lt;br /&gt;
 -- Current Database: `sugarcrm`&lt;br /&gt;
&lt;br /&gt;
=== Backup all the databases:===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
The following example takes a backup of  all the database of the MySQL instance.&lt;br /&gt;
&lt;br /&gt;
# mysqldump -u root -ptmppassword --all-databases &amp;gt; /tmp/all-database.sql&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
=== Backup a specific table:===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
In this example, we backup only the accounts_contacts table from sugarcrm database.&lt;br /&gt;
&lt;br /&gt;
mysqldump -u root -ptmppassword sugarcrm accounts_contacts &amp;gt; /tmp/sugarcrm_accounts_contacts.sql &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;h4 class=&amp;quot;yellowbackground&amp;quot;&amp;gt;Script to import a CSV File into an existing Database&amp;lt;/h4&amp;gt; ==&lt;br /&gt;
&amp;lt;p style=&amp;quot;background-color: #77a8f7; font-weight: bold; font-size: 1.2rem;&amp;quot;&amp;gt;The csv file has to be in a specific directory. /var/lib/mysql-files/&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p style=&amp;quot;background-color: #77a8f7; font-weight: bold; font-size: 1.2rem;&amp;quot;&amp;gt;The table has to already exist &amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
mysql kartest &amp;lt;&amp;lt;EOF&lt;br /&gt;
truncate table songs;&lt;br /&gt;
load data infile &amp;#039;/var/lib/mysql-files/songs.csv&amp;#039;&lt;br /&gt;
into table songs&lt;br /&gt;
fields terminated by &amp;#039;|&amp;#039;&lt;br /&gt;
enclosed by &amp;#039;&amp;quot;&amp;#039;&lt;br /&gt;
lines terminated by &amp;#039;\n&amp;#039;&lt;br /&gt;
ignore 1 rows;&lt;br /&gt;
EOF&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Copy csv file to a dir and run script on server ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
fxcopy=&amp;quot;/mnt/c/Users/john/Dropbox/Shining Cabinet/My Stuff/sqlitedb&amp;quot;&lt;br /&gt;
scp -i ~/.ssh/linode &amp;quot;$fxcopy/filename.csv&amp;quot; 1.1.1.1:/var/lib/mysql-files/&lt;br /&gt;
sleep 4&lt;br /&gt;
ssh -i ~/.ssh/linode root@1.1.1.1 /var/www/scripts/import.sh&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Fixing error connecting to database from AppSheet ==&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; The permission has to be fixed to the old version in mysql server &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
 ALTER USER &amp;#039;username&amp;#039;@&amp;#039;%&amp;#039; IDENTIFIED WITH mysql_native_password BY &amp;#039;password&amp;#039;;&lt;br /&gt;
 FLUSH PRIVILEGES;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Restore Database==&lt;br /&gt;
&amp;lt;p style=&amp;quot;background-color: #77a8f7; font-weight: bold; font-size: 1.2rem;&amp;quot;&amp;gt; I used this to restore r512 from the dumped .sql file in 2025 &amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p style=&amp;quot;font-weight: bold;font-size: 1.3rem&amp;quot;&amp;gt; I tried to restore it using phpmyadmin, but it did not work, got many errors. probably because it was a raw sql dump backup&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* log into mysql&lt;br /&gt;
&lt;br /&gt;
 mysql&lt;br /&gt;
 use databasename&lt;br /&gt;
 source /path/to/sql/file.sql;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 mysql -u username -p database &amp;lt; dump_file.sql&lt;br /&gt;
&lt;br /&gt;
== Set / Change Mysql Password ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Set / change / reset the MySQL root password on Ubuntu Linux. Enter the following lines in your terminal.&lt;br /&gt;
&lt;br /&gt;
Stop the MySQL Server.&lt;br /&gt;
sudo /etc/init.d/mysql stop&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
Start the mysqld configuration.&lt;br /&gt;
sudo mysqld --skip-grant-tables &amp;amp;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
Login to MySQL as root.&lt;br /&gt;
mysql -u root mysql&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
Replace YOURNEWPASSWORD with your new password!&lt;br /&gt;
UPDATE user SET Password=PASSWORD(&amp;#039;YOURNEWPASSWORD&amp;#039;) WHERE User=&amp;#039;root&amp;#039;; FLUSH PRIVILEGES; exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Reset mysql password  ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dpkg-reconfigure mysql-server-5.0&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
dpkg-reconfigure mysql-server-5.1&lt;br /&gt;
&lt;br /&gt;
Depending on which package you have installed.&lt;br /&gt;
&lt;br /&gt;
the will bring up the enter password screen for mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==  ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
[[#MySql Commands My Fav|Back To Top]]-[[Main_Page| Home]]&lt;br /&gt;
[[Category:Mysql]]&lt;/div&gt;</summary>
		<author><name>Bacchas</name></author>
	</entry>
	<entry>
		<id>https://www.r512.com/index.php?title=MYSQL_COMMANDS&amp;diff=2889</id>
		<title>MYSQL COMMANDS</title>
		<link rel="alternate" type="text/html" href="https://www.r512.com/index.php?title=MYSQL_COMMANDS&amp;diff=2889"/>
		<updated>2025-10-06T16:03:03Z</updated>

		<summary type="html">&lt;p&gt;Bacchas: /* Restore Database */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==MySql Commands My Fav ==&lt;br /&gt;
&lt;br /&gt;
Find and Replace the word &amp;quot;GaGa, Ladyy&amp;quot; in Artists and replace with &amp;quot;Lady GaGa&lt;br /&gt;
&lt;br /&gt;
 UPDATE Karaoke set Artists = replace(Artists, &amp;quot;GaGa, Lady&amp;quot;, &amp;quot;Lady GaGa&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
UPDATE wp2_posts &lt;br /&gt;
 SET `post_content`= replace(`post_content`, &amp;quot;&amp;#039; rel=&amp;#039;sexylightbox[]&amp;quot;, &amp;quot;&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Delete&lt;br /&gt;
&lt;br /&gt;
 Delete  FROM `master2011` WHERE id &amp;lt; 1688&lt;br /&gt;
 &lt;br /&gt;
Update single record&lt;br /&gt;
&lt;br /&gt;
 UPDATE Karaoke&lt;br /&gt;
 SET Title = &amp;#039;Size 10 Red Shoe&amp;#039;,&lt;br /&gt;
 Artists = &amp;#039;Big Red Shoes&lt;br /&gt;
 Where DiskId=1234&lt;br /&gt;
&lt;br /&gt;
This will grant all priviliges to the user admin. will only work on local host not remote&lt;br /&gt;
&lt;br /&gt;
 GRANT ALL ON *.* TO admin@localhost WITH GRANT OPTION;&lt;br /&gt;
&lt;br /&gt;
 FLUSH PRIVILEGES;  // this relloads the priviliges&lt;br /&gt;
&lt;br /&gt;
 use databasename // this loads the database&lt;br /&gt;
&lt;br /&gt;
 Show tables //show tables&lt;br /&gt;
&lt;br /&gt;
 Describe tablename//show fields&lt;br /&gt;
&lt;br /&gt;
 select * from tablename where Title Like &amp;quot;%fire%&amp;quot; //returns all instance of fire. you can also &lt;br /&gt;
&lt;br /&gt;
 select count (*) from tablename// returns number of records&lt;br /&gt;
&lt;br /&gt;
 select * from tablename where Diskid=&amp;quot;200&amp;quot;; // shows all records with disk id of 200&lt;br /&gt;
&lt;br /&gt;
 select diskid, track, title, artists from tablename order by title // display defined columns. sort by title&lt;br /&gt;
&lt;br /&gt;
 select artists, count(artists) from Karaoke Group by artists // counts the number of songs  by that artists&lt;br /&gt;
&lt;br /&gt;
 select artists, group_concat(title order by title separator &amp;#039; | &amp;#039; ) from tablename Group by artists // list them songs by artists&lt;br /&gt;
&lt;br /&gt;
 select * from passrequest where match (companyname, state) against (&amp;quot;texas&amp;quot;) //column has to be fulltext search- fulltext search is when you setup the     field proberties for the structure.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ALTER TABLE Karaoke AUTO_INCREMENT=15786 &lt;br /&gt;
Resets the auto_increment, in a situation where some of the most recently added rows were deleted. future insertions will be numbered from 15786 again (unless you still had rows numbered greater than 1234, and then the future insertions will start from the greatest number + 1 ).&lt;br /&gt;
&lt;br /&gt;
DELETE FROM tablename WHERE id=3; // will delete record with id 3&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Create mysql database in ubuntu shell==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
On a default settings, mysql root user do not need a password to authenticate from localhost. In this case, ou can login as root on your mysql server using:&lt;br /&gt;
&lt;br /&gt;
$ mysql -u root&lt;br /&gt;
&lt;br /&gt;
If a password is required, use the extra switch -p:&lt;br /&gt;
$ mysql -u root -p&lt;br /&gt;
Enter password:&lt;br /&gt;
&lt;br /&gt;
Now that you are logged in, we create a database:&lt;br /&gt;
mysql&amp;gt; create database amarokdb;&lt;br /&gt;
Query OK, 1 row affected (0.00 sec)&lt;br /&gt;
&lt;br /&gt;
We allow user amarokuser to connect to the server from localhost using the password amarokpasswd:&lt;br /&gt;
mysql&amp;gt; grant usage on *.* to amarokuser@localhost identified by &amp;#039;amarokpasswd&amp;#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.00 sec)&lt;br /&gt;
&lt;br /&gt;
And finally we grant all privileges on the amarok database to this user:&lt;br /&gt;
mysql&amp;gt; grant all privileges on amarokdb.* to amarokuser@localhost ;&lt;br /&gt;
Query OK, 0 rows affected (0.00 sec)&lt;br /&gt;
&lt;br /&gt;
And that&amp;#039;s it. You can now check that you can connect to the MySQL server using this command:&lt;br /&gt;
$ mysql -u amarokuser -p&amp;#039;amarokpasswd&amp;#039; amarokdb&lt;br /&gt;
Your MySQL connection id is 12&lt;br /&gt;
Server version: 5.0.38-Ubuntu_0ubuntu1-log Ubuntu 7.04 distribution&lt;br /&gt;
&lt;br /&gt;
Type &amp;#039;help;&amp;#039; or &amp;#039;\h&amp;#039; for help. Type &amp;#039;\c&amp;#039; to clear the buffer.&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
== securing MYSQL and setting a Password ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/usr/bin/mysql_secure_installation&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Mysql Backup and Restore  ==&lt;br /&gt;
===List Databases===&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Login to server &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 mysql&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; List databases&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 show databases;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;List Tables in a database&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 use databasename&lt;br /&gt;
 show tables;&lt;br /&gt;
&lt;br /&gt;
===Bakcup a single database===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
done from bash - no need to log in to mysql&lt;br /&gt;
mysqldump -u root -ppassword sugarcrm &amp;gt; sugarcrm.sq&lt;br /&gt;
&lt;br /&gt;
syntax&lt;br /&gt;
&lt;br /&gt;
mysqldump -u root -p[root_password] [database_name] &amp;gt; dumpfilename.sql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
===Backup a single table===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mysqldump -u root -ppassword databasename table &amp;gt; sugarcrm.sq&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
===Backup Multiple Database===&lt;br /&gt;
* log into mysql&lt;br /&gt;
&lt;br /&gt;
 mysql -u root -pyourpassword&lt;br /&gt;
 mysql&amp;gt; show databases;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;this will give you a list of databases&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;For example, if you want to take backup of both sugarcrm and bugs database, execute the mysqldump as shown below:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
 mysqldump -u root -ptmppassword --databases bugs sugarcrm &amp;gt; bugs_sugarcrm.sql&lt;br /&gt;
&lt;br /&gt;
* Verify the bugs_sugarcrm.sql dumpfile contains both the database backup.&lt;br /&gt;
&lt;br /&gt;
 # grep -i &amp;quot;Current database:&amp;quot; /tmp/bugs_sugarcrm.sql&lt;br /&gt;
&lt;br /&gt;
 -- Current Database: `mysql`&lt;br /&gt;
&lt;br /&gt;
 -- Current Database: `sugarcrm`&lt;br /&gt;
&lt;br /&gt;
=== Backup all the databases:===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
The following example takes a backup of  all the database of the MySQL instance.&lt;br /&gt;
&lt;br /&gt;
# mysqldump -u root -ptmppassword --all-databases &amp;gt; /tmp/all-database.sql&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
=== Backup a specific table:===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
In this example, we backup only the accounts_contacts table from sugarcrm database.&lt;br /&gt;
&lt;br /&gt;
mysqldump -u root -ptmppassword sugarcrm accounts_contacts &amp;gt; /tmp/sugarcrm_accounts_contacts.sql &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;h4 class=&amp;quot;yellowbackground&amp;quot;&amp;gt;Script to import a CSV File into an existing Database&amp;lt;/h4&amp;gt; ==&lt;br /&gt;
&amp;lt;p style=&amp;quot;background-color: #77a8f7; font-weight: bold; font-size: 1.2rem;&amp;quot;&amp;gt;The csv file has to be in a specific directory. /var/lib/mysql-files/&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p style=&amp;quot;background-color: #77a8f7; font-weight: bold; font-size: 1.2rem;&amp;quot;&amp;gt;The table has to already exist &amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
mysql kartest &amp;lt;&amp;lt;EOF&lt;br /&gt;
truncate table songs;&lt;br /&gt;
load data infile &amp;#039;/var/lib/mysql-files/songs.csv&amp;#039;&lt;br /&gt;
into table songs&lt;br /&gt;
fields terminated by &amp;#039;|&amp;#039;&lt;br /&gt;
enclosed by &amp;#039;&amp;quot;&amp;#039;&lt;br /&gt;
lines terminated by &amp;#039;\n&amp;#039;&lt;br /&gt;
ignore 1 rows;&lt;br /&gt;
EOF&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Copy csv file to a dir and run script on server ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
fxcopy=&amp;quot;/mnt/c/Users/john/Dropbox/Shining Cabinet/My Stuff/sqlitedb&amp;quot;&lt;br /&gt;
scp -i ~/.ssh/linode &amp;quot;$fxcopy/filename.csv&amp;quot; 1.1.1.1:/var/lib/mysql-files/&lt;br /&gt;
sleep 4&lt;br /&gt;
ssh -i ~/.ssh/linode root@1.1.1.1 /var/www/scripts/import.sh&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Fixing error connecting to database from AppSheet ==&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; The permission has to be fixed to the old version in mysql server &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
 ALTER USER &amp;#039;username&amp;#039;@&amp;#039;%&amp;#039; IDENTIFIED WITH mysql_native_password BY &amp;#039;password&amp;#039;;&lt;br /&gt;
 FLUSH PRIVILEGES;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Restore Database==&lt;br /&gt;
&amp;lt;p style=&amp;quot;background-color: #77a8f7; font-weight: bold; font-size: 1.2rem;&amp;quot;&amp;gt; I used this to restore r512 the dumped .sql file in 2025 &amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p style=&amp;quot;font-weight: bold;font-size: 1.3rem&amp;quot;&amp;gt; I tried to restore it using phpmyadmin, but it did not work, got many errors. probably because it was a raw sql dump backup&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* log into mysql&lt;br /&gt;
&lt;br /&gt;
 mysql&lt;br /&gt;
 use databasename&lt;br /&gt;
 source /path/to/sql/file.sql;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 mysql -u username -p database &amp;lt; dump_file.sql&lt;br /&gt;
&lt;br /&gt;
== Set / Change Mysql Password ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Set / change / reset the MySQL root password on Ubuntu Linux. Enter the following lines in your terminal.&lt;br /&gt;
&lt;br /&gt;
Stop the MySQL Server.&lt;br /&gt;
sudo /etc/init.d/mysql stop&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
Start the mysqld configuration.&lt;br /&gt;
sudo mysqld --skip-grant-tables &amp;amp;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
Login to MySQL as root.&lt;br /&gt;
mysql -u root mysql&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
Replace YOURNEWPASSWORD with your new password!&lt;br /&gt;
UPDATE user SET Password=PASSWORD(&amp;#039;YOURNEWPASSWORD&amp;#039;) WHERE User=&amp;#039;root&amp;#039;; FLUSH PRIVILEGES; exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Reset mysql password  ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dpkg-reconfigure mysql-server-5.0&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
dpkg-reconfigure mysql-server-5.1&lt;br /&gt;
&lt;br /&gt;
Depending on which package you have installed.&lt;br /&gt;
&lt;br /&gt;
the will bring up the enter password screen for mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==  ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
[[#MySql Commands My Fav|Back To Top]]-[[Main_Page| Home]]&lt;br /&gt;
[[Category:Mysql]]&lt;/div&gt;</summary>
		<author><name>Bacchas</name></author>
	</entry>
	<entry>
		<id>https://www.r512.com/index.php?title=MYSQL_COMMANDS&amp;diff=2888</id>
		<title>MYSQL COMMANDS</title>
		<link rel="alternate" type="text/html" href="https://www.r512.com/index.php?title=MYSQL_COMMANDS&amp;diff=2888"/>
		<updated>2025-10-06T15:58:54Z</updated>

		<summary type="html">&lt;p&gt;Bacchas: /* Script to import a CSV File into an existing Database */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==MySql Commands My Fav ==&lt;br /&gt;
&lt;br /&gt;
Find and Replace the word &amp;quot;GaGa, Ladyy&amp;quot; in Artists and replace with &amp;quot;Lady GaGa&lt;br /&gt;
&lt;br /&gt;
 UPDATE Karaoke set Artists = replace(Artists, &amp;quot;GaGa, Lady&amp;quot;, &amp;quot;Lady GaGa&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
UPDATE wp2_posts &lt;br /&gt;
 SET `post_content`= replace(`post_content`, &amp;quot;&amp;#039; rel=&amp;#039;sexylightbox[]&amp;quot;, &amp;quot;&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Delete&lt;br /&gt;
&lt;br /&gt;
 Delete  FROM `master2011` WHERE id &amp;lt; 1688&lt;br /&gt;
 &lt;br /&gt;
Update single record&lt;br /&gt;
&lt;br /&gt;
 UPDATE Karaoke&lt;br /&gt;
 SET Title = &amp;#039;Size 10 Red Shoe&amp;#039;,&lt;br /&gt;
 Artists = &amp;#039;Big Red Shoes&lt;br /&gt;
 Where DiskId=1234&lt;br /&gt;
&lt;br /&gt;
This will grant all priviliges to the user admin. will only work on local host not remote&lt;br /&gt;
&lt;br /&gt;
 GRANT ALL ON *.* TO admin@localhost WITH GRANT OPTION;&lt;br /&gt;
&lt;br /&gt;
 FLUSH PRIVILEGES;  // this relloads the priviliges&lt;br /&gt;
&lt;br /&gt;
 use databasename // this loads the database&lt;br /&gt;
&lt;br /&gt;
 Show tables //show tables&lt;br /&gt;
&lt;br /&gt;
 Describe tablename//show fields&lt;br /&gt;
&lt;br /&gt;
 select * from tablename where Title Like &amp;quot;%fire%&amp;quot; //returns all instance of fire. you can also &lt;br /&gt;
&lt;br /&gt;
 select count (*) from tablename// returns number of records&lt;br /&gt;
&lt;br /&gt;
 select * from tablename where Diskid=&amp;quot;200&amp;quot;; // shows all records with disk id of 200&lt;br /&gt;
&lt;br /&gt;
 select diskid, track, title, artists from tablename order by title // display defined columns. sort by title&lt;br /&gt;
&lt;br /&gt;
 select artists, count(artists) from Karaoke Group by artists // counts the number of songs  by that artists&lt;br /&gt;
&lt;br /&gt;
 select artists, group_concat(title order by title separator &amp;#039; | &amp;#039; ) from tablename Group by artists // list them songs by artists&lt;br /&gt;
&lt;br /&gt;
 select * from passrequest where match (companyname, state) against (&amp;quot;texas&amp;quot;) //column has to be fulltext search- fulltext search is when you setup the     field proberties for the structure.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ALTER TABLE Karaoke AUTO_INCREMENT=15786 &lt;br /&gt;
Resets the auto_increment, in a situation where some of the most recently added rows were deleted. future insertions will be numbered from 15786 again (unless you still had rows numbered greater than 1234, and then the future insertions will start from the greatest number + 1 ).&lt;br /&gt;
&lt;br /&gt;
DELETE FROM tablename WHERE id=3; // will delete record with id 3&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Create mysql database in ubuntu shell==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
On a default settings, mysql root user do not need a password to authenticate from localhost. In this case, ou can login as root on your mysql server using:&lt;br /&gt;
&lt;br /&gt;
$ mysql -u root&lt;br /&gt;
&lt;br /&gt;
If a password is required, use the extra switch -p:&lt;br /&gt;
$ mysql -u root -p&lt;br /&gt;
Enter password:&lt;br /&gt;
&lt;br /&gt;
Now that you are logged in, we create a database:&lt;br /&gt;
mysql&amp;gt; create database amarokdb;&lt;br /&gt;
Query OK, 1 row affected (0.00 sec)&lt;br /&gt;
&lt;br /&gt;
We allow user amarokuser to connect to the server from localhost using the password amarokpasswd:&lt;br /&gt;
mysql&amp;gt; grant usage on *.* to amarokuser@localhost identified by &amp;#039;amarokpasswd&amp;#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.00 sec)&lt;br /&gt;
&lt;br /&gt;
And finally we grant all privileges on the amarok database to this user:&lt;br /&gt;
mysql&amp;gt; grant all privileges on amarokdb.* to amarokuser@localhost ;&lt;br /&gt;
Query OK, 0 rows affected (0.00 sec)&lt;br /&gt;
&lt;br /&gt;
And that&amp;#039;s it. You can now check that you can connect to the MySQL server using this command:&lt;br /&gt;
$ mysql -u amarokuser -p&amp;#039;amarokpasswd&amp;#039; amarokdb&lt;br /&gt;
Your MySQL connection id is 12&lt;br /&gt;
Server version: 5.0.38-Ubuntu_0ubuntu1-log Ubuntu 7.04 distribution&lt;br /&gt;
&lt;br /&gt;
Type &amp;#039;help;&amp;#039; or &amp;#039;\h&amp;#039; for help. Type &amp;#039;\c&amp;#039; to clear the buffer.&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
== securing MYSQL and setting a Password ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/usr/bin/mysql_secure_installation&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Mysql Backup and Restore  ==&lt;br /&gt;
===List Databases===&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Login to server &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 mysql&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; List databases&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 show databases;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;List Tables in a database&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 use databasename&lt;br /&gt;
 show tables;&lt;br /&gt;
&lt;br /&gt;
===Bakcup a single database===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
done from bash - no need to log in to mysql&lt;br /&gt;
mysqldump -u root -ppassword sugarcrm &amp;gt; sugarcrm.sq&lt;br /&gt;
&lt;br /&gt;
syntax&lt;br /&gt;
&lt;br /&gt;
mysqldump -u root -p[root_password] [database_name] &amp;gt; dumpfilename.sql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
===Backup a single table===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mysqldump -u root -ppassword databasename table &amp;gt; sugarcrm.sq&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
===Backup Multiple Database===&lt;br /&gt;
* log into mysql&lt;br /&gt;
&lt;br /&gt;
 mysql -u root -pyourpassword&lt;br /&gt;
 mysql&amp;gt; show databases;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;this will give you a list of databases&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;For example, if you want to take backup of both sugarcrm and bugs database, execute the mysqldump as shown below:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
 mysqldump -u root -ptmppassword --databases bugs sugarcrm &amp;gt; bugs_sugarcrm.sql&lt;br /&gt;
&lt;br /&gt;
* Verify the bugs_sugarcrm.sql dumpfile contains both the database backup.&lt;br /&gt;
&lt;br /&gt;
 # grep -i &amp;quot;Current database:&amp;quot; /tmp/bugs_sugarcrm.sql&lt;br /&gt;
&lt;br /&gt;
 -- Current Database: `mysql`&lt;br /&gt;
&lt;br /&gt;
 -- Current Database: `sugarcrm`&lt;br /&gt;
&lt;br /&gt;
=== Backup all the databases:===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
The following example takes a backup of  all the database of the MySQL instance.&lt;br /&gt;
&lt;br /&gt;
# mysqldump -u root -ptmppassword --all-databases &amp;gt; /tmp/all-database.sql&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
=== Backup a specific table:===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
In this example, we backup only the accounts_contacts table from sugarcrm database.&lt;br /&gt;
&lt;br /&gt;
mysqldump -u root -ptmppassword sugarcrm accounts_contacts &amp;gt; /tmp/sugarcrm_accounts_contacts.sql &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;h4 class=&amp;quot;yellowbackground&amp;quot;&amp;gt;Script to import a CSV File into an existing Database&amp;lt;/h4&amp;gt; ==&lt;br /&gt;
&amp;lt;p style=&amp;quot;background-color: #77a8f7; font-weight: bold; font-size: 1.2rem;&amp;quot;&amp;gt;The csv file has to be in a specific directory. /var/lib/mysql-files/&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p style=&amp;quot;background-color: #77a8f7; font-weight: bold; font-size: 1.2rem;&amp;quot;&amp;gt;The table has to already exist &amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
mysql kartest &amp;lt;&amp;lt;EOF&lt;br /&gt;
truncate table songs;&lt;br /&gt;
load data infile &amp;#039;/var/lib/mysql-files/songs.csv&amp;#039;&lt;br /&gt;
into table songs&lt;br /&gt;
fields terminated by &amp;#039;|&amp;#039;&lt;br /&gt;
enclosed by &amp;#039;&amp;quot;&amp;#039;&lt;br /&gt;
lines terminated by &amp;#039;\n&amp;#039;&lt;br /&gt;
ignore 1 rows;&lt;br /&gt;
EOF&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Copy csv file to a dir and run script on server ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
fxcopy=&amp;quot;/mnt/c/Users/john/Dropbox/Shining Cabinet/My Stuff/sqlitedb&amp;quot;&lt;br /&gt;
scp -i ~/.ssh/linode &amp;quot;$fxcopy/filename.csv&amp;quot; 1.1.1.1:/var/lib/mysql-files/&lt;br /&gt;
sleep 4&lt;br /&gt;
ssh -i ~/.ssh/linode root@1.1.1.1 /var/www/scripts/import.sh&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Fixing error connecting to database from AppSheet ==&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; The permission has to be fixed to the old version in mysql server &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
 ALTER USER &amp;#039;username&amp;#039;@&amp;#039;%&amp;#039; IDENTIFIED WITH mysql_native_password BY &amp;#039;password&amp;#039;;&lt;br /&gt;
 FLUSH PRIVILEGES;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Restore Database==&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; I used this to restore r512 the dumped .sql file in 2025 &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; I tried to restore it using phpmyadmin, but it did not work, got many errors. probably because it was a raw sql dump backup&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* log into mysql&lt;br /&gt;
 mysql&lt;br /&gt;
 use databasename&lt;br /&gt;
 source /path/to/sql/file.sql;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mysql -u username -p database &amp;lt; dump_file.sql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Set / Change Mysql Password ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Set / change / reset the MySQL root password on Ubuntu Linux. Enter the following lines in your terminal.&lt;br /&gt;
&lt;br /&gt;
Stop the MySQL Server.&lt;br /&gt;
sudo /etc/init.d/mysql stop&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
Start the mysqld configuration.&lt;br /&gt;
sudo mysqld --skip-grant-tables &amp;amp;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
Login to MySQL as root.&lt;br /&gt;
mysql -u root mysql&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
Replace YOURNEWPASSWORD with your new password!&lt;br /&gt;
UPDATE user SET Password=PASSWORD(&amp;#039;YOURNEWPASSWORD&amp;#039;) WHERE User=&amp;#039;root&amp;#039;; FLUSH PRIVILEGES; exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Reset mysql password  ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dpkg-reconfigure mysql-server-5.0&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
dpkg-reconfigure mysql-server-5.1&lt;br /&gt;
&lt;br /&gt;
Depending on which package you have installed.&lt;br /&gt;
&lt;br /&gt;
the will bring up the enter password screen for mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==  ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
[[#MySql Commands My Fav|Back To Top]]-[[Main_Page| Home]]&lt;br /&gt;
[[Category:Mysql]]&lt;/div&gt;</summary>
		<author><name>Bacchas</name></author>
	</entry>
	<entry>
		<id>https://www.r512.com/index.php?title=MYSQL_COMMANDS&amp;diff=2887</id>
		<title>MYSQL COMMANDS</title>
		<link rel="alternate" type="text/html" href="https://www.r512.com/index.php?title=MYSQL_COMMANDS&amp;diff=2887"/>
		<updated>2025-10-06T15:57:59Z</updated>

		<summary type="html">&lt;p&gt;Bacchas: /* Script to import a CSV File into an existing Database */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==MySql Commands My Fav ==&lt;br /&gt;
&lt;br /&gt;
Find and Replace the word &amp;quot;GaGa, Ladyy&amp;quot; in Artists and replace with &amp;quot;Lady GaGa&lt;br /&gt;
&lt;br /&gt;
 UPDATE Karaoke set Artists = replace(Artists, &amp;quot;GaGa, Lady&amp;quot;, &amp;quot;Lady GaGa&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
UPDATE wp2_posts &lt;br /&gt;
 SET `post_content`= replace(`post_content`, &amp;quot;&amp;#039; rel=&amp;#039;sexylightbox[]&amp;quot;, &amp;quot;&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Delete&lt;br /&gt;
&lt;br /&gt;
 Delete  FROM `master2011` WHERE id &amp;lt; 1688&lt;br /&gt;
 &lt;br /&gt;
Update single record&lt;br /&gt;
&lt;br /&gt;
 UPDATE Karaoke&lt;br /&gt;
 SET Title = &amp;#039;Size 10 Red Shoe&amp;#039;,&lt;br /&gt;
 Artists = &amp;#039;Big Red Shoes&lt;br /&gt;
 Where DiskId=1234&lt;br /&gt;
&lt;br /&gt;
This will grant all priviliges to the user admin. will only work on local host not remote&lt;br /&gt;
&lt;br /&gt;
 GRANT ALL ON *.* TO admin@localhost WITH GRANT OPTION;&lt;br /&gt;
&lt;br /&gt;
 FLUSH PRIVILEGES;  // this relloads the priviliges&lt;br /&gt;
&lt;br /&gt;
 use databasename // this loads the database&lt;br /&gt;
&lt;br /&gt;
 Show tables //show tables&lt;br /&gt;
&lt;br /&gt;
 Describe tablename//show fields&lt;br /&gt;
&lt;br /&gt;
 select * from tablename where Title Like &amp;quot;%fire%&amp;quot; //returns all instance of fire. you can also &lt;br /&gt;
&lt;br /&gt;
 select count (*) from tablename// returns number of records&lt;br /&gt;
&lt;br /&gt;
 select * from tablename where Diskid=&amp;quot;200&amp;quot;; // shows all records with disk id of 200&lt;br /&gt;
&lt;br /&gt;
 select diskid, track, title, artists from tablename order by title // display defined columns. sort by title&lt;br /&gt;
&lt;br /&gt;
 select artists, count(artists) from Karaoke Group by artists // counts the number of songs  by that artists&lt;br /&gt;
&lt;br /&gt;
 select artists, group_concat(title order by title separator &amp;#039; | &amp;#039; ) from tablename Group by artists // list them songs by artists&lt;br /&gt;
&lt;br /&gt;
 select * from passrequest where match (companyname, state) against (&amp;quot;texas&amp;quot;) //column has to be fulltext search- fulltext search is when you setup the     field proberties for the structure.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ALTER TABLE Karaoke AUTO_INCREMENT=15786 &lt;br /&gt;
Resets the auto_increment, in a situation where some of the most recently added rows were deleted. future insertions will be numbered from 15786 again (unless you still had rows numbered greater than 1234, and then the future insertions will start from the greatest number + 1 ).&lt;br /&gt;
&lt;br /&gt;
DELETE FROM tablename WHERE id=3; // will delete record with id 3&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Create mysql database in ubuntu shell==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
On a default settings, mysql root user do not need a password to authenticate from localhost. In this case, ou can login as root on your mysql server using:&lt;br /&gt;
&lt;br /&gt;
$ mysql -u root&lt;br /&gt;
&lt;br /&gt;
If a password is required, use the extra switch -p:&lt;br /&gt;
$ mysql -u root -p&lt;br /&gt;
Enter password:&lt;br /&gt;
&lt;br /&gt;
Now that you are logged in, we create a database:&lt;br /&gt;
mysql&amp;gt; create database amarokdb;&lt;br /&gt;
Query OK, 1 row affected (0.00 sec)&lt;br /&gt;
&lt;br /&gt;
We allow user amarokuser to connect to the server from localhost using the password amarokpasswd:&lt;br /&gt;
mysql&amp;gt; grant usage on *.* to amarokuser@localhost identified by &amp;#039;amarokpasswd&amp;#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.00 sec)&lt;br /&gt;
&lt;br /&gt;
And finally we grant all privileges on the amarok database to this user:&lt;br /&gt;
mysql&amp;gt; grant all privileges on amarokdb.* to amarokuser@localhost ;&lt;br /&gt;
Query OK, 0 rows affected (0.00 sec)&lt;br /&gt;
&lt;br /&gt;
And that&amp;#039;s it. You can now check that you can connect to the MySQL server using this command:&lt;br /&gt;
$ mysql -u amarokuser -p&amp;#039;amarokpasswd&amp;#039; amarokdb&lt;br /&gt;
Your MySQL connection id is 12&lt;br /&gt;
Server version: 5.0.38-Ubuntu_0ubuntu1-log Ubuntu 7.04 distribution&lt;br /&gt;
&lt;br /&gt;
Type &amp;#039;help;&amp;#039; or &amp;#039;\h&amp;#039; for help. Type &amp;#039;\c&amp;#039; to clear the buffer.&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
== securing MYSQL and setting a Password ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/usr/bin/mysql_secure_installation&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Mysql Backup and Restore  ==&lt;br /&gt;
===List Databases===&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Login to server &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 mysql&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; List databases&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 show databases;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;List Tables in a database&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 use databasename&lt;br /&gt;
 show tables;&lt;br /&gt;
&lt;br /&gt;
===Bakcup a single database===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
done from bash - no need to log in to mysql&lt;br /&gt;
mysqldump -u root -ppassword sugarcrm &amp;gt; sugarcrm.sq&lt;br /&gt;
&lt;br /&gt;
syntax&lt;br /&gt;
&lt;br /&gt;
mysqldump -u root -p[root_password] [database_name] &amp;gt; dumpfilename.sql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
===Backup a single table===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mysqldump -u root -ppassword databasename table &amp;gt; sugarcrm.sq&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
===Backup Multiple Database===&lt;br /&gt;
* log into mysql&lt;br /&gt;
&lt;br /&gt;
 mysql -u root -pyourpassword&lt;br /&gt;
 mysql&amp;gt; show databases;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;this will give you a list of databases&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;For example, if you want to take backup of both sugarcrm and bugs database, execute the mysqldump as shown below:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
 mysqldump -u root -ptmppassword --databases bugs sugarcrm &amp;gt; bugs_sugarcrm.sql&lt;br /&gt;
&lt;br /&gt;
* Verify the bugs_sugarcrm.sql dumpfile contains both the database backup.&lt;br /&gt;
&lt;br /&gt;
 # grep -i &amp;quot;Current database:&amp;quot; /tmp/bugs_sugarcrm.sql&lt;br /&gt;
&lt;br /&gt;
 -- Current Database: `mysql`&lt;br /&gt;
&lt;br /&gt;
 -- Current Database: `sugarcrm`&lt;br /&gt;
&lt;br /&gt;
=== Backup all the databases:===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
The following example takes a backup of  all the database of the MySQL instance.&lt;br /&gt;
&lt;br /&gt;
# mysqldump -u root -ptmppassword --all-databases &amp;gt; /tmp/all-database.sql&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
=== Backup a specific table:===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
In this example, we backup only the accounts_contacts table from sugarcrm database.&lt;br /&gt;
&lt;br /&gt;
mysqldump -u root -ptmppassword sugarcrm accounts_contacts &amp;gt; /tmp/sugarcrm_accounts_contacts.sql &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;h4 class=&amp;quot;yellowbackground&amp;quot;&amp;gt;Script to import a CSV File into an existing Database&amp;lt;/h4&amp;gt; ==&lt;br /&gt;
&amp;lt;p style=&amp;quot;background-color: #77a8f7; font-weight: bold; font-size: 1.2rem;&amp;quot;&amp;gt;the csv file has to be in a specific directory. /var/lib/mysql-files/&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;h5 class=&amp;quot;subhead&amp;quot; &amp;gt;The table has to already exist &amp;lt;/h5&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
mysql kartest &amp;lt;&amp;lt;EOF&lt;br /&gt;
truncate table songs;&lt;br /&gt;
load data infile &amp;#039;/var/lib/mysql-files/songs.csv&amp;#039;&lt;br /&gt;
into table songs&lt;br /&gt;
fields terminated by &amp;#039;|&amp;#039;&lt;br /&gt;
enclosed by &amp;#039;&amp;quot;&amp;#039;&lt;br /&gt;
lines terminated by &amp;#039;\n&amp;#039;&lt;br /&gt;
ignore 1 rows;&lt;br /&gt;
EOF&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Copy csv file to a dir and run script on server ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
fxcopy=&amp;quot;/mnt/c/Users/john/Dropbox/Shining Cabinet/My Stuff/sqlitedb&amp;quot;&lt;br /&gt;
scp -i ~/.ssh/linode &amp;quot;$fxcopy/filename.csv&amp;quot; 1.1.1.1:/var/lib/mysql-files/&lt;br /&gt;
sleep 4&lt;br /&gt;
ssh -i ~/.ssh/linode root@1.1.1.1 /var/www/scripts/import.sh&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Fixing error connecting to database from AppSheet ==&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; The permission has to be fixed to the old version in mysql server &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
 ALTER USER &amp;#039;username&amp;#039;@&amp;#039;%&amp;#039; IDENTIFIED WITH mysql_native_password BY &amp;#039;password&amp;#039;;&lt;br /&gt;
 FLUSH PRIVILEGES;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Restore Database==&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; I used this to restore r512 the dumped .sql file in 2025 &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; I tried to restore it using phpmyadmin, but it did not work, got many errors. probably because it was a raw sql dump backup&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* log into mysql&lt;br /&gt;
 mysql&lt;br /&gt;
 use databasename&lt;br /&gt;
 source /path/to/sql/file.sql;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mysql -u username -p database &amp;lt; dump_file.sql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Set / Change Mysql Password ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Set / change / reset the MySQL root password on Ubuntu Linux. Enter the following lines in your terminal.&lt;br /&gt;
&lt;br /&gt;
Stop the MySQL Server.&lt;br /&gt;
sudo /etc/init.d/mysql stop&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
Start the mysqld configuration.&lt;br /&gt;
sudo mysqld --skip-grant-tables &amp;amp;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
Login to MySQL as root.&lt;br /&gt;
mysql -u root mysql&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
Replace YOURNEWPASSWORD with your new password!&lt;br /&gt;
UPDATE user SET Password=PASSWORD(&amp;#039;YOURNEWPASSWORD&amp;#039;) WHERE User=&amp;#039;root&amp;#039;; FLUSH PRIVILEGES; exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Reset mysql password  ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dpkg-reconfigure mysql-server-5.0&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
dpkg-reconfigure mysql-server-5.1&lt;br /&gt;
&lt;br /&gt;
Depending on which package you have installed.&lt;br /&gt;
&lt;br /&gt;
the will bring up the enter password screen for mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==  ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
[[#MySql Commands My Fav|Back To Top]]-[[Main_Page| Home]]&lt;br /&gt;
[[Category:Mysql]]&lt;/div&gt;</summary>
		<author><name>Bacchas</name></author>
	</entry>
	<entry>
		<id>https://www.r512.com/index.php?title=MYSQL_COMMANDS&amp;diff=2886</id>
		<title>MYSQL COMMANDS</title>
		<link rel="alternate" type="text/html" href="https://www.r512.com/index.php?title=MYSQL_COMMANDS&amp;diff=2886"/>
		<updated>2025-10-06T15:57:22Z</updated>

		<summary type="html">&lt;p&gt;Bacchas: /* Script to import a CSV File into an existing Database */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==MySql Commands My Fav ==&lt;br /&gt;
&lt;br /&gt;
Find and Replace the word &amp;quot;GaGa, Ladyy&amp;quot; in Artists and replace with &amp;quot;Lady GaGa&lt;br /&gt;
&lt;br /&gt;
 UPDATE Karaoke set Artists = replace(Artists, &amp;quot;GaGa, Lady&amp;quot;, &amp;quot;Lady GaGa&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
UPDATE wp2_posts &lt;br /&gt;
 SET `post_content`= replace(`post_content`, &amp;quot;&amp;#039; rel=&amp;#039;sexylightbox[]&amp;quot;, &amp;quot;&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Delete&lt;br /&gt;
&lt;br /&gt;
 Delete  FROM `master2011` WHERE id &amp;lt; 1688&lt;br /&gt;
 &lt;br /&gt;
Update single record&lt;br /&gt;
&lt;br /&gt;
 UPDATE Karaoke&lt;br /&gt;
 SET Title = &amp;#039;Size 10 Red Shoe&amp;#039;,&lt;br /&gt;
 Artists = &amp;#039;Big Red Shoes&lt;br /&gt;
 Where DiskId=1234&lt;br /&gt;
&lt;br /&gt;
This will grant all priviliges to the user admin. will only work on local host not remote&lt;br /&gt;
&lt;br /&gt;
 GRANT ALL ON *.* TO admin@localhost WITH GRANT OPTION;&lt;br /&gt;
&lt;br /&gt;
 FLUSH PRIVILEGES;  // this relloads the priviliges&lt;br /&gt;
&lt;br /&gt;
 use databasename // this loads the database&lt;br /&gt;
&lt;br /&gt;
 Show tables //show tables&lt;br /&gt;
&lt;br /&gt;
 Describe tablename//show fields&lt;br /&gt;
&lt;br /&gt;
 select * from tablename where Title Like &amp;quot;%fire%&amp;quot; //returns all instance of fire. you can also &lt;br /&gt;
&lt;br /&gt;
 select count (*) from tablename// returns number of records&lt;br /&gt;
&lt;br /&gt;
 select * from tablename where Diskid=&amp;quot;200&amp;quot;; // shows all records with disk id of 200&lt;br /&gt;
&lt;br /&gt;
 select diskid, track, title, artists from tablename order by title // display defined columns. sort by title&lt;br /&gt;
&lt;br /&gt;
 select artists, count(artists) from Karaoke Group by artists // counts the number of songs  by that artists&lt;br /&gt;
&lt;br /&gt;
 select artists, group_concat(title order by title separator &amp;#039; | &amp;#039; ) from tablename Group by artists // list them songs by artists&lt;br /&gt;
&lt;br /&gt;
 select * from passrequest where match (companyname, state) against (&amp;quot;texas&amp;quot;) //column has to be fulltext search- fulltext search is when you setup the     field proberties for the structure.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ALTER TABLE Karaoke AUTO_INCREMENT=15786 &lt;br /&gt;
Resets the auto_increment, in a situation where some of the most recently added rows were deleted. future insertions will be numbered from 15786 again (unless you still had rows numbered greater than 1234, and then the future insertions will start from the greatest number + 1 ).&lt;br /&gt;
&lt;br /&gt;
DELETE FROM tablename WHERE id=3; // will delete record with id 3&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Create mysql database in ubuntu shell==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
On a default settings, mysql root user do not need a password to authenticate from localhost. In this case, ou can login as root on your mysql server using:&lt;br /&gt;
&lt;br /&gt;
$ mysql -u root&lt;br /&gt;
&lt;br /&gt;
If a password is required, use the extra switch -p:&lt;br /&gt;
$ mysql -u root -p&lt;br /&gt;
Enter password:&lt;br /&gt;
&lt;br /&gt;
Now that you are logged in, we create a database:&lt;br /&gt;
mysql&amp;gt; create database amarokdb;&lt;br /&gt;
Query OK, 1 row affected (0.00 sec)&lt;br /&gt;
&lt;br /&gt;
We allow user amarokuser to connect to the server from localhost using the password amarokpasswd:&lt;br /&gt;
mysql&amp;gt; grant usage on *.* to amarokuser@localhost identified by &amp;#039;amarokpasswd&amp;#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.00 sec)&lt;br /&gt;
&lt;br /&gt;
And finally we grant all privileges on the amarok database to this user:&lt;br /&gt;
mysql&amp;gt; grant all privileges on amarokdb.* to amarokuser@localhost ;&lt;br /&gt;
Query OK, 0 rows affected (0.00 sec)&lt;br /&gt;
&lt;br /&gt;
And that&amp;#039;s it. You can now check that you can connect to the MySQL server using this command:&lt;br /&gt;
$ mysql -u amarokuser -p&amp;#039;amarokpasswd&amp;#039; amarokdb&lt;br /&gt;
Your MySQL connection id is 12&lt;br /&gt;
Server version: 5.0.38-Ubuntu_0ubuntu1-log Ubuntu 7.04 distribution&lt;br /&gt;
&lt;br /&gt;
Type &amp;#039;help;&amp;#039; or &amp;#039;\h&amp;#039; for help. Type &amp;#039;\c&amp;#039; to clear the buffer.&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
== securing MYSQL and setting a Password ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/usr/bin/mysql_secure_installation&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Mysql Backup and Restore  ==&lt;br /&gt;
===List Databases===&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Login to server &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 mysql&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; List databases&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 show databases;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;List Tables in a database&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 use databasename&lt;br /&gt;
 show tables;&lt;br /&gt;
&lt;br /&gt;
===Bakcup a single database===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
done from bash - no need to log in to mysql&lt;br /&gt;
mysqldump -u root -ppassword sugarcrm &amp;gt; sugarcrm.sq&lt;br /&gt;
&lt;br /&gt;
syntax&lt;br /&gt;
&lt;br /&gt;
mysqldump -u root -p[root_password] [database_name] &amp;gt; dumpfilename.sql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
===Backup a single table===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mysqldump -u root -ppassword databasename table &amp;gt; sugarcrm.sq&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
===Backup Multiple Database===&lt;br /&gt;
* log into mysql&lt;br /&gt;
&lt;br /&gt;
 mysql -u root -pyourpassword&lt;br /&gt;
 mysql&amp;gt; show databases;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;this will give you a list of databases&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;For example, if you want to take backup of both sugarcrm and bugs database, execute the mysqldump as shown below:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
 mysqldump -u root -ptmppassword --databases bugs sugarcrm &amp;gt; bugs_sugarcrm.sql&lt;br /&gt;
&lt;br /&gt;
* Verify the bugs_sugarcrm.sql dumpfile contains both the database backup.&lt;br /&gt;
&lt;br /&gt;
 # grep -i &amp;quot;Current database:&amp;quot; /tmp/bugs_sugarcrm.sql&lt;br /&gt;
&lt;br /&gt;
 -- Current Database: `mysql`&lt;br /&gt;
&lt;br /&gt;
 -- Current Database: `sugarcrm`&lt;br /&gt;
&lt;br /&gt;
=== Backup all the databases:===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
The following example takes a backup of  all the database of the MySQL instance.&lt;br /&gt;
&lt;br /&gt;
# mysqldump -u root -ptmppassword --all-databases &amp;gt; /tmp/all-database.sql&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
=== Backup a specific table:===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
In this example, we backup only the accounts_contacts table from sugarcrm database.&lt;br /&gt;
&lt;br /&gt;
mysqldump -u root -ptmppassword sugarcrm accounts_contacts &amp;gt; /tmp/sugarcrm_accounts_contacts.sql &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;h4 class=&amp;quot;yellowbackground&amp;quot;&amp;gt;Script to import a CSV File into an existing Database&amp;lt;/h4&amp;gt; ==&lt;br /&gt;
&amp;lt;p style=&amp;quot;background-color: #77a8f7; font-size: 1.2rem;&amp;quot;&amp;gt;the csv file has to be in a specific directory. /var/lib/mysql-files/&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;h5 class=&amp;quot;subhead&amp;quot; &amp;gt;The table has to already exist &amp;lt;/h5&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
mysql kartest &amp;lt;&amp;lt;EOF&lt;br /&gt;
truncate table songs;&lt;br /&gt;
load data infile &amp;#039;/var/lib/mysql-files/songs.csv&amp;#039;&lt;br /&gt;
into table songs&lt;br /&gt;
fields terminated by &amp;#039;|&amp;#039;&lt;br /&gt;
enclosed by &amp;#039;&amp;quot;&amp;#039;&lt;br /&gt;
lines terminated by &amp;#039;\n&amp;#039;&lt;br /&gt;
ignore 1 rows;&lt;br /&gt;
EOF&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Copy csv file to a dir and run script on server ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
fxcopy=&amp;quot;/mnt/c/Users/john/Dropbox/Shining Cabinet/My Stuff/sqlitedb&amp;quot;&lt;br /&gt;
scp -i ~/.ssh/linode &amp;quot;$fxcopy/filename.csv&amp;quot; 1.1.1.1:/var/lib/mysql-files/&lt;br /&gt;
sleep 4&lt;br /&gt;
ssh -i ~/.ssh/linode root@1.1.1.1 /var/www/scripts/import.sh&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Fixing error connecting to database from AppSheet ==&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; The permission has to be fixed to the old version in mysql server &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
 ALTER USER &amp;#039;username&amp;#039;@&amp;#039;%&amp;#039; IDENTIFIED WITH mysql_native_password BY &amp;#039;password&amp;#039;;&lt;br /&gt;
 FLUSH PRIVILEGES;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Restore Database==&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; I used this to restore r512 the dumped .sql file in 2025 &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; I tried to restore it using phpmyadmin, but it did not work, got many errors. probably because it was a raw sql dump backup&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* log into mysql&lt;br /&gt;
 mysql&lt;br /&gt;
 use databasename&lt;br /&gt;
 source /path/to/sql/file.sql;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mysql -u username -p database &amp;lt; dump_file.sql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Set / Change Mysql Password ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Set / change / reset the MySQL root password on Ubuntu Linux. Enter the following lines in your terminal.&lt;br /&gt;
&lt;br /&gt;
Stop the MySQL Server.&lt;br /&gt;
sudo /etc/init.d/mysql stop&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
Start the mysqld configuration.&lt;br /&gt;
sudo mysqld --skip-grant-tables &amp;amp;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
Login to MySQL as root.&lt;br /&gt;
mysql -u root mysql&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
Replace YOURNEWPASSWORD with your new password!&lt;br /&gt;
UPDATE user SET Password=PASSWORD(&amp;#039;YOURNEWPASSWORD&amp;#039;) WHERE User=&amp;#039;root&amp;#039;; FLUSH PRIVILEGES; exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Reset mysql password  ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dpkg-reconfigure mysql-server-5.0&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
dpkg-reconfigure mysql-server-5.1&lt;br /&gt;
&lt;br /&gt;
Depending on which package you have installed.&lt;br /&gt;
&lt;br /&gt;
the will bring up the enter password screen for mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==  ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
[[#MySql Commands My Fav|Back To Top]]-[[Main_Page| Home]]&lt;br /&gt;
[[Category:Mysql]]&lt;/div&gt;</summary>
		<author><name>Bacchas</name></author>
	</entry>
	<entry>
		<id>https://www.r512.com/index.php?title=MYSQL_COMMANDS&amp;diff=2885</id>
		<title>MYSQL COMMANDS</title>
		<link rel="alternate" type="text/html" href="https://www.r512.com/index.php?title=MYSQL_COMMANDS&amp;diff=2885"/>
		<updated>2025-10-06T15:56:08Z</updated>

		<summary type="html">&lt;p&gt;Bacchas: /* Script to import a CSV File into an existing Database */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==MySql Commands My Fav ==&lt;br /&gt;
&lt;br /&gt;
Find and Replace the word &amp;quot;GaGa, Ladyy&amp;quot; in Artists and replace with &amp;quot;Lady GaGa&lt;br /&gt;
&lt;br /&gt;
 UPDATE Karaoke set Artists = replace(Artists, &amp;quot;GaGa, Lady&amp;quot;, &amp;quot;Lady GaGa&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
UPDATE wp2_posts &lt;br /&gt;
 SET `post_content`= replace(`post_content`, &amp;quot;&amp;#039; rel=&amp;#039;sexylightbox[]&amp;quot;, &amp;quot;&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Delete&lt;br /&gt;
&lt;br /&gt;
 Delete  FROM `master2011` WHERE id &amp;lt; 1688&lt;br /&gt;
 &lt;br /&gt;
Update single record&lt;br /&gt;
&lt;br /&gt;
 UPDATE Karaoke&lt;br /&gt;
 SET Title = &amp;#039;Size 10 Red Shoe&amp;#039;,&lt;br /&gt;
 Artists = &amp;#039;Big Red Shoes&lt;br /&gt;
 Where DiskId=1234&lt;br /&gt;
&lt;br /&gt;
This will grant all priviliges to the user admin. will only work on local host not remote&lt;br /&gt;
&lt;br /&gt;
 GRANT ALL ON *.* TO admin@localhost WITH GRANT OPTION;&lt;br /&gt;
&lt;br /&gt;
 FLUSH PRIVILEGES;  // this relloads the priviliges&lt;br /&gt;
&lt;br /&gt;
 use databasename // this loads the database&lt;br /&gt;
&lt;br /&gt;
 Show tables //show tables&lt;br /&gt;
&lt;br /&gt;
 Describe tablename//show fields&lt;br /&gt;
&lt;br /&gt;
 select * from tablename where Title Like &amp;quot;%fire%&amp;quot; //returns all instance of fire. you can also &lt;br /&gt;
&lt;br /&gt;
 select count (*) from tablename// returns number of records&lt;br /&gt;
&lt;br /&gt;
 select * from tablename where Diskid=&amp;quot;200&amp;quot;; // shows all records with disk id of 200&lt;br /&gt;
&lt;br /&gt;
 select diskid, track, title, artists from tablename order by title // display defined columns. sort by title&lt;br /&gt;
&lt;br /&gt;
 select artists, count(artists) from Karaoke Group by artists // counts the number of songs  by that artists&lt;br /&gt;
&lt;br /&gt;
 select artists, group_concat(title order by title separator &amp;#039; | &amp;#039; ) from tablename Group by artists // list them songs by artists&lt;br /&gt;
&lt;br /&gt;
 select * from passrequest where match (companyname, state) against (&amp;quot;texas&amp;quot;) //column has to be fulltext search- fulltext search is when you setup the     field proberties for the structure.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ALTER TABLE Karaoke AUTO_INCREMENT=15786 &lt;br /&gt;
Resets the auto_increment, in a situation where some of the most recently added rows were deleted. future insertions will be numbered from 15786 again (unless you still had rows numbered greater than 1234, and then the future insertions will start from the greatest number + 1 ).&lt;br /&gt;
&lt;br /&gt;
DELETE FROM tablename WHERE id=3; // will delete record with id 3&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Create mysql database in ubuntu shell==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
On a default settings, mysql root user do not need a password to authenticate from localhost. In this case, ou can login as root on your mysql server using:&lt;br /&gt;
&lt;br /&gt;
$ mysql -u root&lt;br /&gt;
&lt;br /&gt;
If a password is required, use the extra switch -p:&lt;br /&gt;
$ mysql -u root -p&lt;br /&gt;
Enter password:&lt;br /&gt;
&lt;br /&gt;
Now that you are logged in, we create a database:&lt;br /&gt;
mysql&amp;gt; create database amarokdb;&lt;br /&gt;
Query OK, 1 row affected (0.00 sec)&lt;br /&gt;
&lt;br /&gt;
We allow user amarokuser to connect to the server from localhost using the password amarokpasswd:&lt;br /&gt;
mysql&amp;gt; grant usage on *.* to amarokuser@localhost identified by &amp;#039;amarokpasswd&amp;#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.00 sec)&lt;br /&gt;
&lt;br /&gt;
And finally we grant all privileges on the amarok database to this user:&lt;br /&gt;
mysql&amp;gt; grant all privileges on amarokdb.* to amarokuser@localhost ;&lt;br /&gt;
Query OK, 0 rows affected (0.00 sec)&lt;br /&gt;
&lt;br /&gt;
And that&amp;#039;s it. You can now check that you can connect to the MySQL server using this command:&lt;br /&gt;
$ mysql -u amarokuser -p&amp;#039;amarokpasswd&amp;#039; amarokdb&lt;br /&gt;
Your MySQL connection id is 12&lt;br /&gt;
Server version: 5.0.38-Ubuntu_0ubuntu1-log Ubuntu 7.04 distribution&lt;br /&gt;
&lt;br /&gt;
Type &amp;#039;help;&amp;#039; or &amp;#039;\h&amp;#039; for help. Type &amp;#039;\c&amp;#039; to clear the buffer.&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
== securing MYSQL and setting a Password ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/usr/bin/mysql_secure_installation&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Mysql Backup and Restore  ==&lt;br /&gt;
===List Databases===&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Login to server &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 mysql&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; List databases&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 show databases;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;List Tables in a database&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 use databasename&lt;br /&gt;
 show tables;&lt;br /&gt;
&lt;br /&gt;
===Bakcup a single database===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
done from bash - no need to log in to mysql&lt;br /&gt;
mysqldump -u root -ppassword sugarcrm &amp;gt; sugarcrm.sq&lt;br /&gt;
&lt;br /&gt;
syntax&lt;br /&gt;
&lt;br /&gt;
mysqldump -u root -p[root_password] [database_name] &amp;gt; dumpfilename.sql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
===Backup a single table===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mysqldump -u root -ppassword databasename table &amp;gt; sugarcrm.sq&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
===Backup Multiple Database===&lt;br /&gt;
* log into mysql&lt;br /&gt;
&lt;br /&gt;
 mysql -u root -pyourpassword&lt;br /&gt;
 mysql&amp;gt; show databases;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;this will give you a list of databases&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;For example, if you want to take backup of both sugarcrm and bugs database, execute the mysqldump as shown below:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
 mysqldump -u root -ptmppassword --databases bugs sugarcrm &amp;gt; bugs_sugarcrm.sql&lt;br /&gt;
&lt;br /&gt;
* Verify the bugs_sugarcrm.sql dumpfile contains both the database backup.&lt;br /&gt;
&lt;br /&gt;
 # grep -i &amp;quot;Current database:&amp;quot; /tmp/bugs_sugarcrm.sql&lt;br /&gt;
&lt;br /&gt;
 -- Current Database: `mysql`&lt;br /&gt;
&lt;br /&gt;
 -- Current Database: `sugarcrm`&lt;br /&gt;
&lt;br /&gt;
=== Backup all the databases:===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
The following example takes a backup of  all the database of the MySQL instance.&lt;br /&gt;
&lt;br /&gt;
# mysqldump -u root -ptmppassword --all-databases &amp;gt; /tmp/all-database.sql&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
=== Backup a specific table:===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
In this example, we backup only the accounts_contacts table from sugarcrm database.&lt;br /&gt;
&lt;br /&gt;
mysqldump -u root -ptmppassword sugarcrm accounts_contacts &amp;gt; /tmp/sugarcrm_accounts_contacts.sql &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;h4 class=&amp;quot;yellowbackground&amp;quot;&amp;gt;Script to import a CSV File into an existing Database&amp;lt;/h4&amp;gt; ==&lt;br /&gt;
&amp;lt;p style=&amp;quot;background-color: blue; font-size: 1.2rem;&amp;quot;&amp;gt;the csv file has to be in a specific directory. /var/lib/mysql-files/&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;h5 class=&amp;quot;subhead&amp;quot; &amp;gt;The table has to already exist &amp;lt;/h5&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
mysql kartest &amp;lt;&amp;lt;EOF&lt;br /&gt;
truncate table songs;&lt;br /&gt;
load data infile &amp;#039;/var/lib/mysql-files/songs.csv&amp;#039;&lt;br /&gt;
into table songs&lt;br /&gt;
fields terminated by &amp;#039;|&amp;#039;&lt;br /&gt;
enclosed by &amp;#039;&amp;quot;&amp;#039;&lt;br /&gt;
lines terminated by &amp;#039;\n&amp;#039;&lt;br /&gt;
ignore 1 rows;&lt;br /&gt;
EOF&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Copy csv file to a dir and run script on server ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
fxcopy=&amp;quot;/mnt/c/Users/john/Dropbox/Shining Cabinet/My Stuff/sqlitedb&amp;quot;&lt;br /&gt;
scp -i ~/.ssh/linode &amp;quot;$fxcopy/filename.csv&amp;quot; 1.1.1.1:/var/lib/mysql-files/&lt;br /&gt;
sleep 4&lt;br /&gt;
ssh -i ~/.ssh/linode root@1.1.1.1 /var/www/scripts/import.sh&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Fixing error connecting to database from AppSheet ==&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; The permission has to be fixed to the old version in mysql server &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
 ALTER USER &amp;#039;username&amp;#039;@&amp;#039;%&amp;#039; IDENTIFIED WITH mysql_native_password BY &amp;#039;password&amp;#039;;&lt;br /&gt;
 FLUSH PRIVILEGES;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Restore Database==&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; I used this to restore r512 the dumped .sql file in 2025 &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; I tried to restore it using phpmyadmin, but it did not work, got many errors. probably because it was a raw sql dump backup&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* log into mysql&lt;br /&gt;
 mysql&lt;br /&gt;
 use databasename&lt;br /&gt;
 source /path/to/sql/file.sql;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mysql -u username -p database &amp;lt; dump_file.sql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Set / Change Mysql Password ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Set / change / reset the MySQL root password on Ubuntu Linux. Enter the following lines in your terminal.&lt;br /&gt;
&lt;br /&gt;
Stop the MySQL Server.&lt;br /&gt;
sudo /etc/init.d/mysql stop&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
Start the mysqld configuration.&lt;br /&gt;
sudo mysqld --skip-grant-tables &amp;amp;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
Login to MySQL as root.&lt;br /&gt;
mysql -u root mysql&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
Replace YOURNEWPASSWORD with your new password!&lt;br /&gt;
UPDATE user SET Password=PASSWORD(&amp;#039;YOURNEWPASSWORD&amp;#039;) WHERE User=&amp;#039;root&amp;#039;; FLUSH PRIVILEGES; exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Reset mysql password  ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dpkg-reconfigure mysql-server-5.0&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
dpkg-reconfigure mysql-server-5.1&lt;br /&gt;
&lt;br /&gt;
Depending on which package you have installed.&lt;br /&gt;
&lt;br /&gt;
the will bring up the enter password screen for mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==  ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
[[#MySql Commands My Fav|Back To Top]]-[[Main_Page| Home]]&lt;br /&gt;
[[Category:Mysql]]&lt;/div&gt;</summary>
		<author><name>Bacchas</name></author>
	</entry>
	<entry>
		<id>https://www.r512.com/index.php?title=MYSQL_COMMANDS&amp;diff=2884</id>
		<title>MYSQL COMMANDS</title>
		<link rel="alternate" type="text/html" href="https://www.r512.com/index.php?title=MYSQL_COMMANDS&amp;diff=2884"/>
		<updated>2025-10-06T15:54:02Z</updated>

		<summary type="html">&lt;p&gt;Bacchas: /* Script to import a CSV File into an existing Database */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==MySql Commands My Fav ==&lt;br /&gt;
&lt;br /&gt;
Find and Replace the word &amp;quot;GaGa, Ladyy&amp;quot; in Artists and replace with &amp;quot;Lady GaGa&lt;br /&gt;
&lt;br /&gt;
 UPDATE Karaoke set Artists = replace(Artists, &amp;quot;GaGa, Lady&amp;quot;, &amp;quot;Lady GaGa&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
UPDATE wp2_posts &lt;br /&gt;
 SET `post_content`= replace(`post_content`, &amp;quot;&amp;#039; rel=&amp;#039;sexylightbox[]&amp;quot;, &amp;quot;&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Delete&lt;br /&gt;
&lt;br /&gt;
 Delete  FROM `master2011` WHERE id &amp;lt; 1688&lt;br /&gt;
 &lt;br /&gt;
Update single record&lt;br /&gt;
&lt;br /&gt;
 UPDATE Karaoke&lt;br /&gt;
 SET Title = &amp;#039;Size 10 Red Shoe&amp;#039;,&lt;br /&gt;
 Artists = &amp;#039;Big Red Shoes&lt;br /&gt;
 Where DiskId=1234&lt;br /&gt;
&lt;br /&gt;
This will grant all priviliges to the user admin. will only work on local host not remote&lt;br /&gt;
&lt;br /&gt;
 GRANT ALL ON *.* TO admin@localhost WITH GRANT OPTION;&lt;br /&gt;
&lt;br /&gt;
 FLUSH PRIVILEGES;  // this relloads the priviliges&lt;br /&gt;
&lt;br /&gt;
 use databasename // this loads the database&lt;br /&gt;
&lt;br /&gt;
 Show tables //show tables&lt;br /&gt;
&lt;br /&gt;
 Describe tablename//show fields&lt;br /&gt;
&lt;br /&gt;
 select * from tablename where Title Like &amp;quot;%fire%&amp;quot; //returns all instance of fire. you can also &lt;br /&gt;
&lt;br /&gt;
 select count (*) from tablename// returns number of records&lt;br /&gt;
&lt;br /&gt;
 select * from tablename where Diskid=&amp;quot;200&amp;quot;; // shows all records with disk id of 200&lt;br /&gt;
&lt;br /&gt;
 select diskid, track, title, artists from tablename order by title // display defined columns. sort by title&lt;br /&gt;
&lt;br /&gt;
 select artists, count(artists) from Karaoke Group by artists // counts the number of songs  by that artists&lt;br /&gt;
&lt;br /&gt;
 select artists, group_concat(title order by title separator &amp;#039; | &amp;#039; ) from tablename Group by artists // list them songs by artists&lt;br /&gt;
&lt;br /&gt;
 select * from passrequest where match (companyname, state) against (&amp;quot;texas&amp;quot;) //column has to be fulltext search- fulltext search is when you setup the     field proberties for the structure.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ALTER TABLE Karaoke AUTO_INCREMENT=15786 &lt;br /&gt;
Resets the auto_increment, in a situation where some of the most recently added rows were deleted. future insertions will be numbered from 15786 again (unless you still had rows numbered greater than 1234, and then the future insertions will start from the greatest number + 1 ).&lt;br /&gt;
&lt;br /&gt;
DELETE FROM tablename WHERE id=3; // will delete record with id 3&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Create mysql database in ubuntu shell==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
On a default settings, mysql root user do not need a password to authenticate from localhost. In this case, ou can login as root on your mysql server using:&lt;br /&gt;
&lt;br /&gt;
$ mysql -u root&lt;br /&gt;
&lt;br /&gt;
If a password is required, use the extra switch -p:&lt;br /&gt;
$ mysql -u root -p&lt;br /&gt;
Enter password:&lt;br /&gt;
&lt;br /&gt;
Now that you are logged in, we create a database:&lt;br /&gt;
mysql&amp;gt; create database amarokdb;&lt;br /&gt;
Query OK, 1 row affected (0.00 sec)&lt;br /&gt;
&lt;br /&gt;
We allow user amarokuser to connect to the server from localhost using the password amarokpasswd:&lt;br /&gt;
mysql&amp;gt; grant usage on *.* to amarokuser@localhost identified by &amp;#039;amarokpasswd&amp;#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.00 sec)&lt;br /&gt;
&lt;br /&gt;
And finally we grant all privileges on the amarok database to this user:&lt;br /&gt;
mysql&amp;gt; grant all privileges on amarokdb.* to amarokuser@localhost ;&lt;br /&gt;
Query OK, 0 rows affected (0.00 sec)&lt;br /&gt;
&lt;br /&gt;
And that&amp;#039;s it. You can now check that you can connect to the MySQL server using this command:&lt;br /&gt;
$ mysql -u amarokuser -p&amp;#039;amarokpasswd&amp;#039; amarokdb&lt;br /&gt;
Your MySQL connection id is 12&lt;br /&gt;
Server version: 5.0.38-Ubuntu_0ubuntu1-log Ubuntu 7.04 distribution&lt;br /&gt;
&lt;br /&gt;
Type &amp;#039;help;&amp;#039; or &amp;#039;\h&amp;#039; for help. Type &amp;#039;\c&amp;#039; to clear the buffer.&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
== securing MYSQL and setting a Password ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/usr/bin/mysql_secure_installation&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Mysql Backup and Restore  ==&lt;br /&gt;
===List Databases===&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Login to server &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 mysql&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; List databases&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 show databases;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;List Tables in a database&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 use databasename&lt;br /&gt;
 show tables;&lt;br /&gt;
&lt;br /&gt;
===Bakcup a single database===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
done from bash - no need to log in to mysql&lt;br /&gt;
mysqldump -u root -ppassword sugarcrm &amp;gt; sugarcrm.sq&lt;br /&gt;
&lt;br /&gt;
syntax&lt;br /&gt;
&lt;br /&gt;
mysqldump -u root -p[root_password] [database_name] &amp;gt; dumpfilename.sql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
===Backup a single table===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mysqldump -u root -ppassword databasename table &amp;gt; sugarcrm.sq&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
===Backup Multiple Database===&lt;br /&gt;
* log into mysql&lt;br /&gt;
&lt;br /&gt;
 mysql -u root -pyourpassword&lt;br /&gt;
 mysql&amp;gt; show databases;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;this will give you a list of databases&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;For example, if you want to take backup of both sugarcrm and bugs database, execute the mysqldump as shown below:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
 mysqldump -u root -ptmppassword --databases bugs sugarcrm &amp;gt; bugs_sugarcrm.sql&lt;br /&gt;
&lt;br /&gt;
* Verify the bugs_sugarcrm.sql dumpfile contains both the database backup.&lt;br /&gt;
&lt;br /&gt;
 # grep -i &amp;quot;Current database:&amp;quot; /tmp/bugs_sugarcrm.sql&lt;br /&gt;
&lt;br /&gt;
 -- Current Database: `mysql`&lt;br /&gt;
&lt;br /&gt;
 -- Current Database: `sugarcrm`&lt;br /&gt;
&lt;br /&gt;
=== Backup all the databases:===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
The following example takes a backup of  all the database of the MySQL instance.&lt;br /&gt;
&lt;br /&gt;
# mysqldump -u root -ptmppassword --all-databases &amp;gt; /tmp/all-database.sql&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
=== Backup a specific table:===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
In this example, we backup only the accounts_contacts table from sugarcrm database.&lt;br /&gt;
&lt;br /&gt;
mysqldump -u root -ptmppassword sugarcrm accounts_contacts &amp;gt; /tmp/sugarcrm_accounts_contacts.sql &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;h4 class=&amp;quot;yellowbackground&amp;quot;&amp;gt;Script to import a CSV File into an existing Database&amp;lt;/h4&amp;gt; ==&lt;br /&gt;
&amp;lt;h5 class=&amp;quot;bluebackground&amp;quot; &amp;gt;the csv file has to be in a specific directory. /var/lib/mysql-files/&amp;lt;/h5&amp;gt;&lt;br /&gt;
&amp;lt;h5 class=&amp;quot;subhead&amp;quot; &amp;gt;The table has to already exist &amp;lt;/h5&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
mysql kartest &amp;lt;&amp;lt;EOF&lt;br /&gt;
truncate table songs;&lt;br /&gt;
load data infile &amp;#039;/var/lib/mysql-files/songs.csv&amp;#039;&lt;br /&gt;
into table songs&lt;br /&gt;
fields terminated by &amp;#039;|&amp;#039;&lt;br /&gt;
enclosed by &amp;#039;&amp;quot;&amp;#039;&lt;br /&gt;
lines terminated by &amp;#039;\n&amp;#039;&lt;br /&gt;
ignore 1 rows;&lt;br /&gt;
EOF&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Copy csv file to a dir and run script on server ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
fxcopy=&amp;quot;/mnt/c/Users/john/Dropbox/Shining Cabinet/My Stuff/sqlitedb&amp;quot;&lt;br /&gt;
scp -i ~/.ssh/linode &amp;quot;$fxcopy/filename.csv&amp;quot; 1.1.1.1:/var/lib/mysql-files/&lt;br /&gt;
sleep 4&lt;br /&gt;
ssh -i ~/.ssh/linode root@1.1.1.1 /var/www/scripts/import.sh&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Fixing error connecting to database from AppSheet ==&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; The permission has to be fixed to the old version in mysql server &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
 ALTER USER &amp;#039;username&amp;#039;@&amp;#039;%&amp;#039; IDENTIFIED WITH mysql_native_password BY &amp;#039;password&amp;#039;;&lt;br /&gt;
 FLUSH PRIVILEGES;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Restore Database==&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; I used this to restore r512 the dumped .sql file in 2025 &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; I tried to restore it using phpmyadmin, but it did not work, got many errors. probably because it was a raw sql dump backup&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* log into mysql&lt;br /&gt;
 mysql&lt;br /&gt;
 use databasename&lt;br /&gt;
 source /path/to/sql/file.sql;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mysql -u username -p database &amp;lt; dump_file.sql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Set / Change Mysql Password ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Set / change / reset the MySQL root password on Ubuntu Linux. Enter the following lines in your terminal.&lt;br /&gt;
&lt;br /&gt;
Stop the MySQL Server.&lt;br /&gt;
sudo /etc/init.d/mysql stop&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
Start the mysqld configuration.&lt;br /&gt;
sudo mysqld --skip-grant-tables &amp;amp;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
Login to MySQL as root.&lt;br /&gt;
mysql -u root mysql&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
Replace YOURNEWPASSWORD with your new password!&lt;br /&gt;
UPDATE user SET Password=PASSWORD(&amp;#039;YOURNEWPASSWORD&amp;#039;) WHERE User=&amp;#039;root&amp;#039;; FLUSH PRIVILEGES; exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Reset mysql password  ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dpkg-reconfigure mysql-server-5.0&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
dpkg-reconfigure mysql-server-5.1&lt;br /&gt;
&lt;br /&gt;
Depending on which package you have installed.&lt;br /&gt;
&lt;br /&gt;
the will bring up the enter password screen for mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==  ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
[[#MySql Commands My Fav|Back To Top]]-[[Main_Page| Home]]&lt;br /&gt;
[[Category:Mysql]]&lt;/div&gt;</summary>
		<author><name>Bacchas</name></author>
	</entry>
	<entry>
		<id>https://www.r512.com/index.php?title=MYSQL_COMMANDS&amp;diff=2883</id>
		<title>MYSQL COMMANDS</title>
		<link rel="alternate" type="text/html" href="https://www.r512.com/index.php?title=MYSQL_COMMANDS&amp;diff=2883"/>
		<updated>2025-10-06T15:53:11Z</updated>

		<summary type="html">&lt;p&gt;Bacchas: /* Script to import a CSV File into an existing Database */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==MySql Commands My Fav ==&lt;br /&gt;
&lt;br /&gt;
Find and Replace the word &amp;quot;GaGa, Ladyy&amp;quot; in Artists and replace with &amp;quot;Lady GaGa&lt;br /&gt;
&lt;br /&gt;
 UPDATE Karaoke set Artists = replace(Artists, &amp;quot;GaGa, Lady&amp;quot;, &amp;quot;Lady GaGa&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
UPDATE wp2_posts &lt;br /&gt;
 SET `post_content`= replace(`post_content`, &amp;quot;&amp;#039; rel=&amp;#039;sexylightbox[]&amp;quot;, &amp;quot;&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Delete&lt;br /&gt;
&lt;br /&gt;
 Delete  FROM `master2011` WHERE id &amp;lt; 1688&lt;br /&gt;
 &lt;br /&gt;
Update single record&lt;br /&gt;
&lt;br /&gt;
 UPDATE Karaoke&lt;br /&gt;
 SET Title = &amp;#039;Size 10 Red Shoe&amp;#039;,&lt;br /&gt;
 Artists = &amp;#039;Big Red Shoes&lt;br /&gt;
 Where DiskId=1234&lt;br /&gt;
&lt;br /&gt;
This will grant all priviliges to the user admin. will only work on local host not remote&lt;br /&gt;
&lt;br /&gt;
 GRANT ALL ON *.* TO admin@localhost WITH GRANT OPTION;&lt;br /&gt;
&lt;br /&gt;
 FLUSH PRIVILEGES;  // this relloads the priviliges&lt;br /&gt;
&lt;br /&gt;
 use databasename // this loads the database&lt;br /&gt;
&lt;br /&gt;
 Show tables //show tables&lt;br /&gt;
&lt;br /&gt;
 Describe tablename//show fields&lt;br /&gt;
&lt;br /&gt;
 select * from tablename where Title Like &amp;quot;%fire%&amp;quot; //returns all instance of fire. you can also &lt;br /&gt;
&lt;br /&gt;
 select count (*) from tablename// returns number of records&lt;br /&gt;
&lt;br /&gt;
 select * from tablename where Diskid=&amp;quot;200&amp;quot;; // shows all records with disk id of 200&lt;br /&gt;
&lt;br /&gt;
 select diskid, track, title, artists from tablename order by title // display defined columns. sort by title&lt;br /&gt;
&lt;br /&gt;
 select artists, count(artists) from Karaoke Group by artists // counts the number of songs  by that artists&lt;br /&gt;
&lt;br /&gt;
 select artists, group_concat(title order by title separator &amp;#039; | &amp;#039; ) from tablename Group by artists // list them songs by artists&lt;br /&gt;
&lt;br /&gt;
 select * from passrequest where match (companyname, state) against (&amp;quot;texas&amp;quot;) //column has to be fulltext search- fulltext search is when you setup the     field proberties for the structure.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ALTER TABLE Karaoke AUTO_INCREMENT=15786 &lt;br /&gt;
Resets the auto_increment, in a situation where some of the most recently added rows were deleted. future insertions will be numbered from 15786 again (unless you still had rows numbered greater than 1234, and then the future insertions will start from the greatest number + 1 ).&lt;br /&gt;
&lt;br /&gt;
DELETE FROM tablename WHERE id=3; // will delete record with id 3&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Create mysql database in ubuntu shell==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
On a default settings, mysql root user do not need a password to authenticate from localhost. In this case, ou can login as root on your mysql server using:&lt;br /&gt;
&lt;br /&gt;
$ mysql -u root&lt;br /&gt;
&lt;br /&gt;
If a password is required, use the extra switch -p:&lt;br /&gt;
$ mysql -u root -p&lt;br /&gt;
Enter password:&lt;br /&gt;
&lt;br /&gt;
Now that you are logged in, we create a database:&lt;br /&gt;
mysql&amp;gt; create database amarokdb;&lt;br /&gt;
Query OK, 1 row affected (0.00 sec)&lt;br /&gt;
&lt;br /&gt;
We allow user amarokuser to connect to the server from localhost using the password amarokpasswd:&lt;br /&gt;
mysql&amp;gt; grant usage on *.* to amarokuser@localhost identified by &amp;#039;amarokpasswd&amp;#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.00 sec)&lt;br /&gt;
&lt;br /&gt;
And finally we grant all privileges on the amarok database to this user:&lt;br /&gt;
mysql&amp;gt; grant all privileges on amarokdb.* to amarokuser@localhost ;&lt;br /&gt;
Query OK, 0 rows affected (0.00 sec)&lt;br /&gt;
&lt;br /&gt;
And that&amp;#039;s it. You can now check that you can connect to the MySQL server using this command:&lt;br /&gt;
$ mysql -u amarokuser -p&amp;#039;amarokpasswd&amp;#039; amarokdb&lt;br /&gt;
Your MySQL connection id is 12&lt;br /&gt;
Server version: 5.0.38-Ubuntu_0ubuntu1-log Ubuntu 7.04 distribution&lt;br /&gt;
&lt;br /&gt;
Type &amp;#039;help;&amp;#039; or &amp;#039;\h&amp;#039; for help. Type &amp;#039;\c&amp;#039; to clear the buffer.&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
== securing MYSQL and setting a Password ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/usr/bin/mysql_secure_installation&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Mysql Backup and Restore  ==&lt;br /&gt;
===List Databases===&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Login to server &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 mysql&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; List databases&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 show databases;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;List Tables in a database&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 use databasename&lt;br /&gt;
 show tables;&lt;br /&gt;
&lt;br /&gt;
===Bakcup a single database===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
done from bash - no need to log in to mysql&lt;br /&gt;
mysqldump -u root -ppassword sugarcrm &amp;gt; sugarcrm.sq&lt;br /&gt;
&lt;br /&gt;
syntax&lt;br /&gt;
&lt;br /&gt;
mysqldump -u root -p[root_password] [database_name] &amp;gt; dumpfilename.sql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
===Backup a single table===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mysqldump -u root -ppassword databasename table &amp;gt; sugarcrm.sq&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
===Backup Multiple Database===&lt;br /&gt;
* log into mysql&lt;br /&gt;
&lt;br /&gt;
 mysql -u root -pyourpassword&lt;br /&gt;
 mysql&amp;gt; show databases;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;this will give you a list of databases&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;For example, if you want to take backup of both sugarcrm and bugs database, execute the mysqldump as shown below:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
 mysqldump -u root -ptmppassword --databases bugs sugarcrm &amp;gt; bugs_sugarcrm.sql&lt;br /&gt;
&lt;br /&gt;
* Verify the bugs_sugarcrm.sql dumpfile contains both the database backup.&lt;br /&gt;
&lt;br /&gt;
 # grep -i &amp;quot;Current database:&amp;quot; /tmp/bugs_sugarcrm.sql&lt;br /&gt;
&lt;br /&gt;
 -- Current Database: `mysql`&lt;br /&gt;
&lt;br /&gt;
 -- Current Database: `sugarcrm`&lt;br /&gt;
&lt;br /&gt;
=== Backup all the databases:===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
The following example takes a backup of  all the database of the MySQL instance.&lt;br /&gt;
&lt;br /&gt;
# mysqldump -u root -ptmppassword --all-databases &amp;gt; /tmp/all-database.sql&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
=== Backup a specific table:===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
In this example, we backup only the accounts_contacts table from sugarcrm database.&lt;br /&gt;
&lt;br /&gt;
mysqldump -u root -ptmppassword sugarcrm accounts_contacts &amp;gt; /tmp/sugarcrm_accounts_contacts.sql &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;h4 class=&amp;quot;yellowbackground&amp;quot;&amp;gt;Script to import a CSV File into an existing Database&amp;lt;/h4&amp;gt; ==&lt;br /&gt;
&amp;lt;p class=&amp;quot;bluebackground&amp;quot; &amp;gt;the csv file has to be in a specific directory. /var/lib/mysql-files/&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p class=&amp;quot;subhead&amp;quot; &amp;gt;The table has to already exist &amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
mysql kartest &amp;lt;&amp;lt;EOF&lt;br /&gt;
truncate table songs;&lt;br /&gt;
load data infile &amp;#039;/var/lib/mysql-files/songs.csv&amp;#039;&lt;br /&gt;
into table songs&lt;br /&gt;
fields terminated by &amp;#039;|&amp;#039;&lt;br /&gt;
enclosed by &amp;#039;&amp;quot;&amp;#039;&lt;br /&gt;
lines terminated by &amp;#039;\n&amp;#039;&lt;br /&gt;
ignore 1 rows;&lt;br /&gt;
EOF&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Copy csv file to a dir and run script on server ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
fxcopy=&amp;quot;/mnt/c/Users/john/Dropbox/Shining Cabinet/My Stuff/sqlitedb&amp;quot;&lt;br /&gt;
scp -i ~/.ssh/linode &amp;quot;$fxcopy/filename.csv&amp;quot; 1.1.1.1:/var/lib/mysql-files/&lt;br /&gt;
sleep 4&lt;br /&gt;
ssh -i ~/.ssh/linode root@1.1.1.1 /var/www/scripts/import.sh&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Fixing error connecting to database from AppSheet ==&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; The permission has to be fixed to the old version in mysql server &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
 ALTER USER &amp;#039;username&amp;#039;@&amp;#039;%&amp;#039; IDENTIFIED WITH mysql_native_password BY &amp;#039;password&amp;#039;;&lt;br /&gt;
 FLUSH PRIVILEGES;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Restore Database==&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; I used this to restore r512 the dumped .sql file in 2025 &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; I tried to restore it using phpmyadmin, but it did not work, got many errors. probably because it was a raw sql dump backup&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* log into mysql&lt;br /&gt;
 mysql&lt;br /&gt;
 use databasename&lt;br /&gt;
 source /path/to/sql/file.sql;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mysql -u username -p database &amp;lt; dump_file.sql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Set / Change Mysql Password ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Set / change / reset the MySQL root password on Ubuntu Linux. Enter the following lines in your terminal.&lt;br /&gt;
&lt;br /&gt;
Stop the MySQL Server.&lt;br /&gt;
sudo /etc/init.d/mysql stop&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
Start the mysqld configuration.&lt;br /&gt;
sudo mysqld --skip-grant-tables &amp;amp;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
Login to MySQL as root.&lt;br /&gt;
mysql -u root mysql&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
Replace YOURNEWPASSWORD with your new password!&lt;br /&gt;
UPDATE user SET Password=PASSWORD(&amp;#039;YOURNEWPASSWORD&amp;#039;) WHERE User=&amp;#039;root&amp;#039;; FLUSH PRIVILEGES; exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Reset mysql password  ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dpkg-reconfigure mysql-server-5.0&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
dpkg-reconfigure mysql-server-5.1&lt;br /&gt;
&lt;br /&gt;
Depending on which package you have installed.&lt;br /&gt;
&lt;br /&gt;
the will bring up the enter password screen for mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==  ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
[[#MySql Commands My Fav|Back To Top]]-[[Main_Page| Home]]&lt;br /&gt;
[[Category:Mysql]]&lt;/div&gt;</summary>
		<author><name>Bacchas</name></author>
	</entry>
	<entry>
		<id>https://www.r512.com/index.php?title=MYSQL_COMMANDS&amp;diff=2882</id>
		<title>MYSQL COMMANDS</title>
		<link rel="alternate" type="text/html" href="https://www.r512.com/index.php?title=MYSQL_COMMANDS&amp;diff=2882"/>
		<updated>2025-10-06T15:50:46Z</updated>

		<summary type="html">&lt;p&gt;Bacchas: /* Script to import a CSV File into an existing Database */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==MySql Commands My Fav ==&lt;br /&gt;
&lt;br /&gt;
Find and Replace the word &amp;quot;GaGa, Ladyy&amp;quot; in Artists and replace with &amp;quot;Lady GaGa&lt;br /&gt;
&lt;br /&gt;
 UPDATE Karaoke set Artists = replace(Artists, &amp;quot;GaGa, Lady&amp;quot;, &amp;quot;Lady GaGa&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
UPDATE wp2_posts &lt;br /&gt;
 SET `post_content`= replace(`post_content`, &amp;quot;&amp;#039; rel=&amp;#039;sexylightbox[]&amp;quot;, &amp;quot;&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Delete&lt;br /&gt;
&lt;br /&gt;
 Delete  FROM `master2011` WHERE id &amp;lt; 1688&lt;br /&gt;
 &lt;br /&gt;
Update single record&lt;br /&gt;
&lt;br /&gt;
 UPDATE Karaoke&lt;br /&gt;
 SET Title = &amp;#039;Size 10 Red Shoe&amp;#039;,&lt;br /&gt;
 Artists = &amp;#039;Big Red Shoes&lt;br /&gt;
 Where DiskId=1234&lt;br /&gt;
&lt;br /&gt;
This will grant all priviliges to the user admin. will only work on local host not remote&lt;br /&gt;
&lt;br /&gt;
 GRANT ALL ON *.* TO admin@localhost WITH GRANT OPTION;&lt;br /&gt;
&lt;br /&gt;
 FLUSH PRIVILEGES;  // this relloads the priviliges&lt;br /&gt;
&lt;br /&gt;
 use databasename // this loads the database&lt;br /&gt;
&lt;br /&gt;
 Show tables //show tables&lt;br /&gt;
&lt;br /&gt;
 Describe tablename//show fields&lt;br /&gt;
&lt;br /&gt;
 select * from tablename where Title Like &amp;quot;%fire%&amp;quot; //returns all instance of fire. you can also &lt;br /&gt;
&lt;br /&gt;
 select count (*) from tablename// returns number of records&lt;br /&gt;
&lt;br /&gt;
 select * from tablename where Diskid=&amp;quot;200&amp;quot;; // shows all records with disk id of 200&lt;br /&gt;
&lt;br /&gt;
 select diskid, track, title, artists from tablename order by title // display defined columns. sort by title&lt;br /&gt;
&lt;br /&gt;
 select artists, count(artists) from Karaoke Group by artists // counts the number of songs  by that artists&lt;br /&gt;
&lt;br /&gt;
 select artists, group_concat(title order by title separator &amp;#039; | &amp;#039; ) from tablename Group by artists // list them songs by artists&lt;br /&gt;
&lt;br /&gt;
 select * from passrequest where match (companyname, state) against (&amp;quot;texas&amp;quot;) //column has to be fulltext search- fulltext search is when you setup the     field proberties for the structure.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ALTER TABLE Karaoke AUTO_INCREMENT=15786 &lt;br /&gt;
Resets the auto_increment, in a situation where some of the most recently added rows were deleted. future insertions will be numbered from 15786 again (unless you still had rows numbered greater than 1234, and then the future insertions will start from the greatest number + 1 ).&lt;br /&gt;
&lt;br /&gt;
DELETE FROM tablename WHERE id=3; // will delete record with id 3&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Create mysql database in ubuntu shell==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
On a default settings, mysql root user do not need a password to authenticate from localhost. In this case, ou can login as root on your mysql server using:&lt;br /&gt;
&lt;br /&gt;
$ mysql -u root&lt;br /&gt;
&lt;br /&gt;
If a password is required, use the extra switch -p:&lt;br /&gt;
$ mysql -u root -p&lt;br /&gt;
Enter password:&lt;br /&gt;
&lt;br /&gt;
Now that you are logged in, we create a database:&lt;br /&gt;
mysql&amp;gt; create database amarokdb;&lt;br /&gt;
Query OK, 1 row affected (0.00 sec)&lt;br /&gt;
&lt;br /&gt;
We allow user amarokuser to connect to the server from localhost using the password amarokpasswd:&lt;br /&gt;
mysql&amp;gt; grant usage on *.* to amarokuser@localhost identified by &amp;#039;amarokpasswd&amp;#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.00 sec)&lt;br /&gt;
&lt;br /&gt;
And finally we grant all privileges on the amarok database to this user:&lt;br /&gt;
mysql&amp;gt; grant all privileges on amarokdb.* to amarokuser@localhost ;&lt;br /&gt;
Query OK, 0 rows affected (0.00 sec)&lt;br /&gt;
&lt;br /&gt;
And that&amp;#039;s it. You can now check that you can connect to the MySQL server using this command:&lt;br /&gt;
$ mysql -u amarokuser -p&amp;#039;amarokpasswd&amp;#039; amarokdb&lt;br /&gt;
Your MySQL connection id is 12&lt;br /&gt;
Server version: 5.0.38-Ubuntu_0ubuntu1-log Ubuntu 7.04 distribution&lt;br /&gt;
&lt;br /&gt;
Type &amp;#039;help;&amp;#039; or &amp;#039;\h&amp;#039; for help. Type &amp;#039;\c&amp;#039; to clear the buffer.&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
== securing MYSQL and setting a Password ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/usr/bin/mysql_secure_installation&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Mysql Backup and Restore  ==&lt;br /&gt;
===List Databases===&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Login to server &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 mysql&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; List databases&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 show databases;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;List Tables in a database&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 use databasename&lt;br /&gt;
 show tables;&lt;br /&gt;
&lt;br /&gt;
===Bakcup a single database===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
done from bash - no need to log in to mysql&lt;br /&gt;
mysqldump -u root -ppassword sugarcrm &amp;gt; sugarcrm.sq&lt;br /&gt;
&lt;br /&gt;
syntax&lt;br /&gt;
&lt;br /&gt;
mysqldump -u root -p[root_password] [database_name] &amp;gt; dumpfilename.sql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
===Backup a single table===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mysqldump -u root -ppassword databasename table &amp;gt; sugarcrm.sq&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
===Backup Multiple Database===&lt;br /&gt;
* log into mysql&lt;br /&gt;
&lt;br /&gt;
 mysql -u root -pyourpassword&lt;br /&gt;
 mysql&amp;gt; show databases;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;this will give you a list of databases&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;For example, if you want to take backup of both sugarcrm and bugs database, execute the mysqldump as shown below:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
 mysqldump -u root -ptmppassword --databases bugs sugarcrm &amp;gt; bugs_sugarcrm.sql&lt;br /&gt;
&lt;br /&gt;
* Verify the bugs_sugarcrm.sql dumpfile contains both the database backup.&lt;br /&gt;
&lt;br /&gt;
 # grep -i &amp;quot;Current database:&amp;quot; /tmp/bugs_sugarcrm.sql&lt;br /&gt;
&lt;br /&gt;
 -- Current Database: `mysql`&lt;br /&gt;
&lt;br /&gt;
 -- Current Database: `sugarcrm`&lt;br /&gt;
&lt;br /&gt;
=== Backup all the databases:===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
The following example takes a backup of  all the database of the MySQL instance.&lt;br /&gt;
&lt;br /&gt;
# mysqldump -u root -ptmppassword --all-databases &amp;gt; /tmp/all-database.sql&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
=== Backup a specific table:===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
In this example, we backup only the accounts_contacts table from sugarcrm database.&lt;br /&gt;
&lt;br /&gt;
mysqldump -u root -ptmppassword sugarcrm accounts_contacts &amp;gt; /tmp/sugarcrm_accounts_contacts.sql &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;h4 class=&amp;quot;yellowbackground&amp;quot;&amp;gt;Script to import a CSV File into an existing Database&amp;lt;/h4&amp;gt; ==&lt;br /&gt;
&amp;lt;p class=&amp;quot;subhead&amp;quot; &amp;gt;the csv file has to be in that specific directory.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p class=&amp;quot;subhead&amp;quot; &amp;gt;The table has to already exist &amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
mysql kartest &amp;lt;&amp;lt;EOF&lt;br /&gt;
truncate table songs;&lt;br /&gt;
load data infile &amp;#039;/var/lib/mysql-files/songs.csv&amp;#039;&lt;br /&gt;
into table songs&lt;br /&gt;
fields terminated by &amp;#039;|&amp;#039;&lt;br /&gt;
enclosed by &amp;#039;&amp;quot;&amp;#039;&lt;br /&gt;
lines terminated by &amp;#039;\n&amp;#039;&lt;br /&gt;
ignore 1 rows;&lt;br /&gt;
EOF&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Copy csv file to a dir and run script on server ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
fxcopy=&amp;quot;/mnt/c/Users/john/Dropbox/Shining Cabinet/My Stuff/sqlitedb&amp;quot;&lt;br /&gt;
scp -i ~/.ssh/linode &amp;quot;$fxcopy/filename.csv&amp;quot; 1.1.1.1:/var/lib/mysql-files/&lt;br /&gt;
sleep 4&lt;br /&gt;
ssh -i ~/.ssh/linode root@1.1.1.1 /var/www/scripts/import.sh&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Fixing error connecting to database from AppSheet ==&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; The permission has to be fixed to the old version in mysql server &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
 ALTER USER &amp;#039;username&amp;#039;@&amp;#039;%&amp;#039; IDENTIFIED WITH mysql_native_password BY &amp;#039;password&amp;#039;;&lt;br /&gt;
 FLUSH PRIVILEGES;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Restore Database==&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; I used this to restore r512 the dumped .sql file in 2025 &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; I tried to restore it using phpmyadmin, but it did not work, got many errors. probably because it was a raw sql dump backup&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* log into mysql&lt;br /&gt;
 mysql&lt;br /&gt;
 use databasename&lt;br /&gt;
 source /path/to/sql/file.sql;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mysql -u username -p database &amp;lt; dump_file.sql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Set / Change Mysql Password ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Set / change / reset the MySQL root password on Ubuntu Linux. Enter the following lines in your terminal.&lt;br /&gt;
&lt;br /&gt;
Stop the MySQL Server.&lt;br /&gt;
sudo /etc/init.d/mysql stop&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
Start the mysqld configuration.&lt;br /&gt;
sudo mysqld --skip-grant-tables &amp;amp;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
Login to MySQL as root.&lt;br /&gt;
mysql -u root mysql&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
Replace YOURNEWPASSWORD with your new password!&lt;br /&gt;
UPDATE user SET Password=PASSWORD(&amp;#039;YOURNEWPASSWORD&amp;#039;) WHERE User=&amp;#039;root&amp;#039;; FLUSH PRIVILEGES; exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Reset mysql password  ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dpkg-reconfigure mysql-server-5.0&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
dpkg-reconfigure mysql-server-5.1&lt;br /&gt;
&lt;br /&gt;
Depending on which package you have installed.&lt;br /&gt;
&lt;br /&gt;
the will bring up the enter password screen for mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==  ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
[[#MySql Commands My Fav|Back To Top]]-[[Main_Page| Home]]&lt;br /&gt;
[[Category:Mysql]]&lt;/div&gt;</summary>
		<author><name>Bacchas</name></author>
	</entry>
	<entry>
		<id>https://www.r512.com/index.php?title=APPSHEET&amp;diff=2881</id>
		<title>APPSHEET</title>
		<link rel="alternate" type="text/html" href="https://www.r512.com/index.php?title=APPSHEET&amp;diff=2881"/>
		<updated>2025-10-06T14:58:46Z</updated>

		<summary type="html">&lt;p&gt;Bacchas: /* Fix permission error when connecting to a mysql database */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Fix permission error when connecting to a mysql database ==&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;On the mysql server, loginto mysql then run command&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
 ALTER USER &amp;#039;username&amp;#039;@&amp;#039;%&amp;#039; IDENTIFIED WITH mysql_native_password BY &amp;#039;password!&amp;#039;;&lt;br /&gt;
 FLUSH PRIVILEGES;&lt;/div&gt;</summary>
		<author><name>Bacchas</name></author>
	</entry>
	<entry>
		<id>https://www.r512.com/index.php?title=APPSHEET&amp;diff=2880</id>
		<title>APPSHEET</title>
		<link rel="alternate" type="text/html" href="https://www.r512.com/index.php?title=APPSHEET&amp;diff=2880"/>
		<updated>2025-10-06T14:58:20Z</updated>

		<summary type="html">&lt;p&gt;Bacchas: Created page with &amp;quot;== Fix permission error when connecting to a mysql database == &amp;#039;&amp;#039;&amp;#039;On the mysql server, loginto mysql then run command&amp;#039;&amp;#039;&amp;#039;   ALTER USER &amp;#039;bacchas&amp;#039;@&amp;#039;%&amp;#039; IDENTIFIED WITH mysql_native_password BY &amp;#039;Outwater24!&amp;#039;;  FLUSH PRIVILEGES;&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Fix permission error when connecting to a mysql database ==&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;On the mysql server, loginto mysql then run command&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
 ALTER USER &amp;#039;bacchas&amp;#039;@&amp;#039;%&amp;#039; IDENTIFIED WITH mysql_native_password BY &amp;#039;Outwater24!&amp;#039;;&lt;br /&gt;
 FLUSH PRIVILEGES;&lt;/div&gt;</summary>
		<author><name>Bacchas</name></author>
	</entry>
	<entry>
		<id>https://www.r512.com/index.php?title=Main_Page&amp;diff=2879</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="https://www.r512.com/index.php?title=Main_Page&amp;diff=2879"/>
		<updated>2025-10-06T14:56:41Z</updated>

		<summary type="html">&lt;p&gt;Bacchas: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==[[APPSHEET]]==&lt;br /&gt;
== [[AWS|Amazon Cloud Service]] ==&lt;br /&gt;
== [[Bash]] ==&lt;br /&gt;
== [[Bluhost]] ==&lt;br /&gt;
==[[Centos OS]] ==&lt;br /&gt;
&lt;br /&gt;
== [[Docker]]==&lt;br /&gt;
== [[Github]]==&lt;br /&gt;
==[[Google Sheets]]==&lt;br /&gt;
== [[Hacking|Hacking And Security ]] ==&lt;br /&gt;
==[[Hardware]]==&lt;br /&gt;
==[[IOS Apps]]==&lt;br /&gt;
==[[JavaScript]]==&lt;br /&gt;
==[[Linode]]==&lt;br /&gt;
==[[Login and reset Forget Password]]==&lt;br /&gt;
== [[Math]] ==&lt;br /&gt;
== [[Mac]] ==&lt;br /&gt;
== [[Mysql]] ==&lt;br /&gt;
== [[Networking]] ==&lt;br /&gt;
== [[Open Source Software]] ==&lt;br /&gt;
== [[Oracle SQL]] ==&lt;br /&gt;
== [[Programming]] ==&lt;br /&gt;
== [[Problem Solution]] ==&lt;br /&gt;
== [[Software Tips]] ==&lt;br /&gt;
==[[Tailscale]]==&lt;br /&gt;
== [[Utilities]] ==&lt;br /&gt;
== [[Ubuntu Tips]] ==&lt;br /&gt;
&lt;br /&gt;
== [[Web Links]] ==&lt;br /&gt;
== [[Windows]] ==&lt;br /&gt;
==[[Virtualization]]==&lt;/div&gt;</summary>
		<author><name>Bacchas</name></author>
	</entry>
	<entry>
		<id>https://www.r512.com/index.php?title=MYSQL_COMMANDS&amp;diff=2878</id>
		<title>MYSQL COMMANDS</title>
		<link rel="alternate" type="text/html" href="https://www.r512.com/index.php?title=MYSQL_COMMANDS&amp;diff=2878"/>
		<updated>2025-10-06T14:54:26Z</updated>

		<summary type="html">&lt;p&gt;Bacchas: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==MySql Commands My Fav ==&lt;br /&gt;
&lt;br /&gt;
Find and Replace the word &amp;quot;GaGa, Ladyy&amp;quot; in Artists and replace with &amp;quot;Lady GaGa&lt;br /&gt;
&lt;br /&gt;
 UPDATE Karaoke set Artists = replace(Artists, &amp;quot;GaGa, Lady&amp;quot;, &amp;quot;Lady GaGa&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
UPDATE wp2_posts &lt;br /&gt;
 SET `post_content`= replace(`post_content`, &amp;quot;&amp;#039; rel=&amp;#039;sexylightbox[]&amp;quot;, &amp;quot;&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Delete&lt;br /&gt;
&lt;br /&gt;
 Delete  FROM `master2011` WHERE id &amp;lt; 1688&lt;br /&gt;
 &lt;br /&gt;
Update single record&lt;br /&gt;
&lt;br /&gt;
 UPDATE Karaoke&lt;br /&gt;
 SET Title = &amp;#039;Size 10 Red Shoe&amp;#039;,&lt;br /&gt;
 Artists = &amp;#039;Big Red Shoes&lt;br /&gt;
 Where DiskId=1234&lt;br /&gt;
&lt;br /&gt;
This will grant all priviliges to the user admin. will only work on local host not remote&lt;br /&gt;
&lt;br /&gt;
 GRANT ALL ON *.* TO admin@localhost WITH GRANT OPTION;&lt;br /&gt;
&lt;br /&gt;
 FLUSH PRIVILEGES;  // this relloads the priviliges&lt;br /&gt;
&lt;br /&gt;
 use databasename // this loads the database&lt;br /&gt;
&lt;br /&gt;
 Show tables //show tables&lt;br /&gt;
&lt;br /&gt;
 Describe tablename//show fields&lt;br /&gt;
&lt;br /&gt;
 select * from tablename where Title Like &amp;quot;%fire%&amp;quot; //returns all instance of fire. you can also &lt;br /&gt;
&lt;br /&gt;
 select count (*) from tablename// returns number of records&lt;br /&gt;
&lt;br /&gt;
 select * from tablename where Diskid=&amp;quot;200&amp;quot;; // shows all records with disk id of 200&lt;br /&gt;
&lt;br /&gt;
 select diskid, track, title, artists from tablename order by title // display defined columns. sort by title&lt;br /&gt;
&lt;br /&gt;
 select artists, count(artists) from Karaoke Group by artists // counts the number of songs  by that artists&lt;br /&gt;
&lt;br /&gt;
 select artists, group_concat(title order by title separator &amp;#039; | &amp;#039; ) from tablename Group by artists // list them songs by artists&lt;br /&gt;
&lt;br /&gt;
 select * from passrequest where match (companyname, state) against (&amp;quot;texas&amp;quot;) //column has to be fulltext search- fulltext search is when you setup the     field proberties for the structure.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ALTER TABLE Karaoke AUTO_INCREMENT=15786 &lt;br /&gt;
Resets the auto_increment, in a situation where some of the most recently added rows were deleted. future insertions will be numbered from 15786 again (unless you still had rows numbered greater than 1234, and then the future insertions will start from the greatest number + 1 ).&lt;br /&gt;
&lt;br /&gt;
DELETE FROM tablename WHERE id=3; // will delete record with id 3&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Create mysql database in ubuntu shell==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
On a default settings, mysql root user do not need a password to authenticate from localhost. In this case, ou can login as root on your mysql server using:&lt;br /&gt;
&lt;br /&gt;
$ mysql -u root&lt;br /&gt;
&lt;br /&gt;
If a password is required, use the extra switch -p:&lt;br /&gt;
$ mysql -u root -p&lt;br /&gt;
Enter password:&lt;br /&gt;
&lt;br /&gt;
Now that you are logged in, we create a database:&lt;br /&gt;
mysql&amp;gt; create database amarokdb;&lt;br /&gt;
Query OK, 1 row affected (0.00 sec)&lt;br /&gt;
&lt;br /&gt;
We allow user amarokuser to connect to the server from localhost using the password amarokpasswd:&lt;br /&gt;
mysql&amp;gt; grant usage on *.* to amarokuser@localhost identified by &amp;#039;amarokpasswd&amp;#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.00 sec)&lt;br /&gt;
&lt;br /&gt;
And finally we grant all privileges on the amarok database to this user:&lt;br /&gt;
mysql&amp;gt; grant all privileges on amarokdb.* to amarokuser@localhost ;&lt;br /&gt;
Query OK, 0 rows affected (0.00 sec)&lt;br /&gt;
&lt;br /&gt;
And that&amp;#039;s it. You can now check that you can connect to the MySQL server using this command:&lt;br /&gt;
$ mysql -u amarokuser -p&amp;#039;amarokpasswd&amp;#039; amarokdb&lt;br /&gt;
Your MySQL connection id is 12&lt;br /&gt;
Server version: 5.0.38-Ubuntu_0ubuntu1-log Ubuntu 7.04 distribution&lt;br /&gt;
&lt;br /&gt;
Type &amp;#039;help;&amp;#039; or &amp;#039;\h&amp;#039; for help. Type &amp;#039;\c&amp;#039; to clear the buffer.&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
== securing MYSQL and setting a Password ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/usr/bin/mysql_secure_installation&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Mysql Backup and Restore  ==&lt;br /&gt;
===List Databases===&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Login to server &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 mysql&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; List databases&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 show databases;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;List Tables in a database&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 use databasename&lt;br /&gt;
 show tables;&lt;br /&gt;
&lt;br /&gt;
===Bakcup a single database===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
done from bash - no need to log in to mysql&lt;br /&gt;
mysqldump -u root -ppassword sugarcrm &amp;gt; sugarcrm.sq&lt;br /&gt;
&lt;br /&gt;
syntax&lt;br /&gt;
&lt;br /&gt;
mysqldump -u root -p[root_password] [database_name] &amp;gt; dumpfilename.sql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
===Backup a single table===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mysqldump -u root -ppassword databasename table &amp;gt; sugarcrm.sq&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
===Backup Multiple Database===&lt;br /&gt;
* log into mysql&lt;br /&gt;
&lt;br /&gt;
 mysql -u root -pyourpassword&lt;br /&gt;
 mysql&amp;gt; show databases;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;this will give you a list of databases&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;For example, if you want to take backup of both sugarcrm and bugs database, execute the mysqldump as shown below:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
 mysqldump -u root -ptmppassword --databases bugs sugarcrm &amp;gt; bugs_sugarcrm.sql&lt;br /&gt;
&lt;br /&gt;
* Verify the bugs_sugarcrm.sql dumpfile contains both the database backup.&lt;br /&gt;
&lt;br /&gt;
 # grep -i &amp;quot;Current database:&amp;quot; /tmp/bugs_sugarcrm.sql&lt;br /&gt;
&lt;br /&gt;
 -- Current Database: `mysql`&lt;br /&gt;
&lt;br /&gt;
 -- Current Database: `sugarcrm`&lt;br /&gt;
&lt;br /&gt;
=== Backup all the databases:===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
The following example takes a backup of  all the database of the MySQL instance.&lt;br /&gt;
&lt;br /&gt;
# mysqldump -u root -ptmppassword --all-databases &amp;gt; /tmp/all-database.sql&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
=== Backup a specific table:===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
In this example, we backup only the accounts_contacts table from sugarcrm database.&lt;br /&gt;
&lt;br /&gt;
mysqldump -u root -ptmppassword sugarcrm accounts_contacts &amp;gt; /tmp/sugarcrm_accounts_contacts.sql &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;h4 class=&amp;quot;yellowbackground&amp;quot;&amp;gt;Script to import a CSV File into an existing Database&amp;lt;/h4&amp;gt; ==&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; the csv file has to be in that specific directory&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;The table has to already exist&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
mysql kartest &amp;lt;&amp;lt;EOF&lt;br /&gt;
truncate table songs;&lt;br /&gt;
load data infile &amp;#039;/var/lib/mysql-files/songs.csv&amp;#039;&lt;br /&gt;
into table songs&lt;br /&gt;
fields terminated by &amp;#039;|&amp;#039;&lt;br /&gt;
enclosed by &amp;#039;&amp;quot;&amp;#039;&lt;br /&gt;
lines terminated by &amp;#039;\n&amp;#039;&lt;br /&gt;
ignore 1 rows;&lt;br /&gt;
EOF&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Copy csv file to a dir and run script on server ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
fxcopy=&amp;quot;/mnt/c/Users/john/Dropbox/Shining Cabinet/My Stuff/sqlitedb&amp;quot;&lt;br /&gt;
scp -i ~/.ssh/linode &amp;quot;$fxcopy/filename.csv&amp;quot; 1.1.1.1:/var/lib/mysql-files/&lt;br /&gt;
sleep 4&lt;br /&gt;
ssh -i ~/.ssh/linode root@1.1.1.1 /var/www/scripts/import.sh&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Fixing error connecting to database from AppSheet ==&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; The permission has to be fixed to the old version in mysql server &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
 ALTER USER &amp;#039;username&amp;#039;@&amp;#039;%&amp;#039; IDENTIFIED WITH mysql_native_password BY &amp;#039;password&amp;#039;;&lt;br /&gt;
 FLUSH PRIVILEGES;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Restore Database==&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; I used this to restore r512 the dumped .sql file in 2025 &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; I tried to restore it using phpmyadmin, but it did not work, got many errors. probably because it was a raw sql dump backup&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* log into mysql&lt;br /&gt;
 mysql&lt;br /&gt;
 use databasename&lt;br /&gt;
 source /path/to/sql/file.sql;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mysql -u username -p database &amp;lt; dump_file.sql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Set / Change Mysql Password ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Set / change / reset the MySQL root password on Ubuntu Linux. Enter the following lines in your terminal.&lt;br /&gt;
&lt;br /&gt;
Stop the MySQL Server.&lt;br /&gt;
sudo /etc/init.d/mysql stop&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
Start the mysqld configuration.&lt;br /&gt;
sudo mysqld --skip-grant-tables &amp;amp;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
Login to MySQL as root.&lt;br /&gt;
mysql -u root mysql&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
Replace YOURNEWPASSWORD with your new password!&lt;br /&gt;
UPDATE user SET Password=PASSWORD(&amp;#039;YOURNEWPASSWORD&amp;#039;) WHERE User=&amp;#039;root&amp;#039;; FLUSH PRIVILEGES; exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Reset mysql password  ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dpkg-reconfigure mysql-server-5.0&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
dpkg-reconfigure mysql-server-5.1&lt;br /&gt;
&lt;br /&gt;
Depending on which package you have installed.&lt;br /&gt;
&lt;br /&gt;
the will bring up the enter password screen for mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==  ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
[[#MySql Commands My Fav|Back To Top]]-[[Main_Page| Home]]&lt;br /&gt;
[[Category:Mysql]]&lt;/div&gt;</summary>
		<author><name>Bacchas</name></author>
	</entry>
	<entry>
		<id>https://www.r512.com/index.php?title=MYSQL_COMMANDS&amp;diff=2877</id>
		<title>MYSQL COMMANDS</title>
		<link rel="alternate" type="text/html" href="https://www.r512.com/index.php?title=MYSQL_COMMANDS&amp;diff=2877"/>
		<updated>2025-10-06T14:48:23Z</updated>

		<summary type="html">&lt;p&gt;Bacchas: /* Script to import a CSV File into an existing Database */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==MySql Commands My Fav ==&lt;br /&gt;
&lt;br /&gt;
Find and Replace the word &amp;quot;GaGa, Ladyy&amp;quot; in Artists and replace with &amp;quot;Lady GaGa&lt;br /&gt;
&lt;br /&gt;
 UPDATE Karaoke set Artists = replace(Artists, &amp;quot;GaGa, Lady&amp;quot;, &amp;quot;Lady GaGa&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
UPDATE wp2_posts &lt;br /&gt;
 SET `post_content`= replace(`post_content`, &amp;quot;&amp;#039; rel=&amp;#039;sexylightbox[]&amp;quot;, &amp;quot;&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Delete&lt;br /&gt;
&lt;br /&gt;
 Delete  FROM `master2011` WHERE id &amp;lt; 1688&lt;br /&gt;
 &lt;br /&gt;
Update single record&lt;br /&gt;
&lt;br /&gt;
 UPDATE Karaoke&lt;br /&gt;
 SET Title = &amp;#039;Size 10 Red Shoe&amp;#039;,&lt;br /&gt;
 Artists = &amp;#039;Big Red Shoes&lt;br /&gt;
 Where DiskId=1234&lt;br /&gt;
&lt;br /&gt;
This will grant all priviliges to the user admin. will only work on local host not remote&lt;br /&gt;
&lt;br /&gt;
 GRANT ALL ON *.* TO admin@localhost WITH GRANT OPTION;&lt;br /&gt;
&lt;br /&gt;
 FLUSH PRIVILEGES;  // this relloads the priviliges&lt;br /&gt;
&lt;br /&gt;
 use databasename // this loads the database&lt;br /&gt;
&lt;br /&gt;
 Show tables //show tables&lt;br /&gt;
&lt;br /&gt;
 Describe tablename//show fields&lt;br /&gt;
&lt;br /&gt;
 select * from tablename where Title Like &amp;quot;%fire%&amp;quot; //returns all instance of fire. you can also &lt;br /&gt;
&lt;br /&gt;
 select count (*) from tablename// returns number of records&lt;br /&gt;
&lt;br /&gt;
 select * from tablename where Diskid=&amp;quot;200&amp;quot;; // shows all records with disk id of 200&lt;br /&gt;
&lt;br /&gt;
 select diskid, track, title, artists from tablename order by title // display defined columns. sort by title&lt;br /&gt;
&lt;br /&gt;
 select artists, count(artists) from Karaoke Group by artists // counts the number of songs  by that artists&lt;br /&gt;
&lt;br /&gt;
 select artists, group_concat(title order by title separator &amp;#039; | &amp;#039; ) from tablename Group by artists // list them songs by artists&lt;br /&gt;
&lt;br /&gt;
 select * from passrequest where match (companyname, state) against (&amp;quot;texas&amp;quot;) //column has to be fulltext search- fulltext search is when you setup the     field proberties for the structure.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ALTER TABLE Karaoke AUTO_INCREMENT=15786 &lt;br /&gt;
Resets the auto_increment, in a situation where some of the most recently added rows were deleted. future insertions will be numbered from 15786 again (unless you still had rows numbered greater than 1234, and then the future insertions will start from the greatest number + 1 ).&lt;br /&gt;
&lt;br /&gt;
DELETE FROM tablename WHERE id=3; // will delete record with id 3&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Create mysql database in ubuntu shell==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
On a default settings, mysql root user do not need a password to authenticate from localhost. In this case, ou can login as root on your mysql server using:&lt;br /&gt;
&lt;br /&gt;
$ mysql -u root&lt;br /&gt;
&lt;br /&gt;
If a password is required, use the extra switch -p:&lt;br /&gt;
$ mysql -u root -p&lt;br /&gt;
Enter password:&lt;br /&gt;
&lt;br /&gt;
Now that you are logged in, we create a database:&lt;br /&gt;
mysql&amp;gt; create database amarokdb;&lt;br /&gt;
Query OK, 1 row affected (0.00 sec)&lt;br /&gt;
&lt;br /&gt;
We allow user amarokuser to connect to the server from localhost using the password amarokpasswd:&lt;br /&gt;
mysql&amp;gt; grant usage on *.* to amarokuser@localhost identified by &amp;#039;amarokpasswd&amp;#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.00 sec)&lt;br /&gt;
&lt;br /&gt;
And finally we grant all privileges on the amarok database to this user:&lt;br /&gt;
mysql&amp;gt; grant all privileges on amarokdb.* to amarokuser@localhost ;&lt;br /&gt;
Query OK, 0 rows affected (0.00 sec)&lt;br /&gt;
&lt;br /&gt;
And that&amp;#039;s it. You can now check that you can connect to the MySQL server using this command:&lt;br /&gt;
$ mysql -u amarokuser -p&amp;#039;amarokpasswd&amp;#039; amarokdb&lt;br /&gt;
Your MySQL connection id is 12&lt;br /&gt;
Server version: 5.0.38-Ubuntu_0ubuntu1-log Ubuntu 7.04 distribution&lt;br /&gt;
&lt;br /&gt;
Type &amp;#039;help;&amp;#039; or &amp;#039;\h&amp;#039; for help. Type &amp;#039;\c&amp;#039; to clear the buffer.&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
== securing MYSQL and setting a Password ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/usr/bin/mysql_secure_installation&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Mysql Backup and Restore  ==&lt;br /&gt;
===List Databases===&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Login to server &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 mysql&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; List databases&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 show databases;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;List Tables in a database&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 use databasename&lt;br /&gt;
 show tables;&lt;br /&gt;
&lt;br /&gt;
===Bakcup a single database===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
done from bash - no need to log in to mysql&lt;br /&gt;
mysqldump -u root -ppassword sugarcrm &amp;gt; sugarcrm.sq&lt;br /&gt;
&lt;br /&gt;
syntax&lt;br /&gt;
&lt;br /&gt;
mysqldump -u root -p[root_password] [database_name] &amp;gt; dumpfilename.sql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
===Backup a single table===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mysqldump -u root -ppassword databasename table &amp;gt; sugarcrm.sq&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
===Backup Multiple Database===&lt;br /&gt;
* log into mysql&lt;br /&gt;
&lt;br /&gt;
 mysql -u root -pyourpassword&lt;br /&gt;
 mysql&amp;gt; show databases;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;this will give you a list of databases&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;For example, if you want to take backup of both sugarcrm and bugs database, execute the mysqldump as shown below:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
 mysqldump -u root -ptmppassword --databases bugs sugarcrm &amp;gt; bugs_sugarcrm.sql&lt;br /&gt;
&lt;br /&gt;
* Verify the bugs_sugarcrm.sql dumpfile contains both the database backup.&lt;br /&gt;
&lt;br /&gt;
 # grep -i &amp;quot;Current database:&amp;quot; /tmp/bugs_sugarcrm.sql&lt;br /&gt;
&lt;br /&gt;
 -- Current Database: `mysql`&lt;br /&gt;
&lt;br /&gt;
 -- Current Database: `sugarcrm`&lt;br /&gt;
&lt;br /&gt;
=== Backup all the databases:===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
The following example takes a backup of  all the database of the MySQL instance.&lt;br /&gt;
&lt;br /&gt;
# mysqldump -u root -ptmppassword --all-databases &amp;gt; /tmp/all-database.sql&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
=== Backup a specific table:===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
In this example, we backup only the accounts_contacts table from sugarcrm database.&lt;br /&gt;
&lt;br /&gt;
mysqldump -u root -ptmppassword sugarcrm accounts_contacts &amp;gt; /tmp/sugarcrm_accounts_contacts.sql &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;h4 class=&amp;quot;yellowbackground&amp;quot;&amp;gt;Script to import a CSV File into an existing Database&amp;lt;/h4&amp;gt; ==&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; the csv file has to be in that specific directory&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;The table has to already exist&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
mysql kartest &amp;lt;&amp;lt;EOF&lt;br /&gt;
truncate table songs;&lt;br /&gt;
load data infile &amp;#039;/var/lib/mysql-files/songs.csv&amp;#039;&lt;br /&gt;
into table songs&lt;br /&gt;
fields terminated by &amp;#039;|&amp;#039;&lt;br /&gt;
enclosed by &amp;#039;&amp;quot;&amp;#039;&lt;br /&gt;
lines terminated by &amp;#039;\n&amp;#039;&lt;br /&gt;
ignore 1 rows;&lt;br /&gt;
EOF&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Copy csv file to a dir and run script on server ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
fxcopy=&amp;quot;/mnt/c/Users/john/Dropbox/Shining Cabinet/My Stuff/sqlitedb&amp;quot;&lt;br /&gt;
scp -i ~/.ssh/linode &amp;quot;$fxcopy/filename.csv&amp;quot; 1.1.1.1:/var/lib/mysql-files/&lt;br /&gt;
sleep 4&lt;br /&gt;
ssh -i ~/.ssh/linode root@1.1.1.1 /var/www/scripts/import.sh&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Restore Database==&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; I used this to restore r512 the dumped .sql file in 2025 &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; I tried to restore it using phpmyadmin, but it did not work, got many errors. probably because it was a raw sql dump backup&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* log into mysql&lt;br /&gt;
 mysql&lt;br /&gt;
 use databasename&lt;br /&gt;
 source /path/to/sql/file.sql;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mysql -u username -p database &amp;lt; dump_file.sql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Set / Change Mysql Password ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Set / change / reset the MySQL root password on Ubuntu Linux. Enter the following lines in your terminal.&lt;br /&gt;
&lt;br /&gt;
Stop the MySQL Server.&lt;br /&gt;
sudo /etc/init.d/mysql stop&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
Start the mysqld configuration.&lt;br /&gt;
sudo mysqld --skip-grant-tables &amp;amp;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
Login to MySQL as root.&lt;br /&gt;
mysql -u root mysql&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
Replace YOURNEWPASSWORD with your new password!&lt;br /&gt;
UPDATE user SET Password=PASSWORD(&amp;#039;YOURNEWPASSWORD&amp;#039;) WHERE User=&amp;#039;root&amp;#039;; FLUSH PRIVILEGES; exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Reset mysql password  ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dpkg-reconfigure mysql-server-5.0&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
dpkg-reconfigure mysql-server-5.1&lt;br /&gt;
&lt;br /&gt;
Depending on which package you have installed.&lt;br /&gt;
&lt;br /&gt;
the will bring up the enter password screen for mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==  ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Import csv file into Php Myadmin Database  ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Structure has to match exactly or you will get an import error.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Invalid field count in csv input line 1&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make sure you count the fields. if there is 6 fileds (including the key) you must have 6 fields to import&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Fixing error connecting to database from AppSheet ==&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; The permission has to be fixed to the old version in mysql server &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
 ALTER USER &amp;#039;username&amp;#039;@&amp;#039;%&amp;#039; IDENTIFIED WITH mysql_native_password BY &amp;#039;password&amp;#039;;&lt;br /&gt;
 FLUSH PRIVILEGES;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
[[#MySql Commands My Fav|Back To Top]]-[[Main_Page| Home]]&lt;br /&gt;
[[Category:Mysql]]&lt;/div&gt;</summary>
		<author><name>Bacchas</name></author>
	</entry>
	<entry>
		<id>https://www.r512.com/index.php?title=MYSQL_COMMANDS&amp;diff=2876</id>
		<title>MYSQL COMMANDS</title>
		<link rel="alternate" type="text/html" href="https://www.r512.com/index.php?title=MYSQL_COMMANDS&amp;diff=2876"/>
		<updated>2025-10-06T14:48:00Z</updated>

		<summary type="html">&lt;p&gt;Bacchas: /* Script to import a CSV File into an existing Database */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==MySql Commands My Fav ==&lt;br /&gt;
&lt;br /&gt;
Find and Replace the word &amp;quot;GaGa, Ladyy&amp;quot; in Artists and replace with &amp;quot;Lady GaGa&lt;br /&gt;
&lt;br /&gt;
 UPDATE Karaoke set Artists = replace(Artists, &amp;quot;GaGa, Lady&amp;quot;, &amp;quot;Lady GaGa&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
UPDATE wp2_posts &lt;br /&gt;
 SET `post_content`= replace(`post_content`, &amp;quot;&amp;#039; rel=&amp;#039;sexylightbox[]&amp;quot;, &amp;quot;&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Delete&lt;br /&gt;
&lt;br /&gt;
 Delete  FROM `master2011` WHERE id &amp;lt; 1688&lt;br /&gt;
 &lt;br /&gt;
Update single record&lt;br /&gt;
&lt;br /&gt;
 UPDATE Karaoke&lt;br /&gt;
 SET Title = &amp;#039;Size 10 Red Shoe&amp;#039;,&lt;br /&gt;
 Artists = &amp;#039;Big Red Shoes&lt;br /&gt;
 Where DiskId=1234&lt;br /&gt;
&lt;br /&gt;
This will grant all priviliges to the user admin. will only work on local host not remote&lt;br /&gt;
&lt;br /&gt;
 GRANT ALL ON *.* TO admin@localhost WITH GRANT OPTION;&lt;br /&gt;
&lt;br /&gt;
 FLUSH PRIVILEGES;  // this relloads the priviliges&lt;br /&gt;
&lt;br /&gt;
 use databasename // this loads the database&lt;br /&gt;
&lt;br /&gt;
 Show tables //show tables&lt;br /&gt;
&lt;br /&gt;
 Describe tablename//show fields&lt;br /&gt;
&lt;br /&gt;
 select * from tablename where Title Like &amp;quot;%fire%&amp;quot; //returns all instance of fire. you can also &lt;br /&gt;
&lt;br /&gt;
 select count (*) from tablename// returns number of records&lt;br /&gt;
&lt;br /&gt;
 select * from tablename where Diskid=&amp;quot;200&amp;quot;; // shows all records with disk id of 200&lt;br /&gt;
&lt;br /&gt;
 select diskid, track, title, artists from tablename order by title // display defined columns. sort by title&lt;br /&gt;
&lt;br /&gt;
 select artists, count(artists) from Karaoke Group by artists // counts the number of songs  by that artists&lt;br /&gt;
&lt;br /&gt;
 select artists, group_concat(title order by title separator &amp;#039; | &amp;#039; ) from tablename Group by artists // list them songs by artists&lt;br /&gt;
&lt;br /&gt;
 select * from passrequest where match (companyname, state) against (&amp;quot;texas&amp;quot;) //column has to be fulltext search- fulltext search is when you setup the     field proberties for the structure.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ALTER TABLE Karaoke AUTO_INCREMENT=15786 &lt;br /&gt;
Resets the auto_increment, in a situation where some of the most recently added rows were deleted. future insertions will be numbered from 15786 again (unless you still had rows numbered greater than 1234, and then the future insertions will start from the greatest number + 1 ).&lt;br /&gt;
&lt;br /&gt;
DELETE FROM tablename WHERE id=3; // will delete record with id 3&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Create mysql database in ubuntu shell==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
On a default settings, mysql root user do not need a password to authenticate from localhost. In this case, ou can login as root on your mysql server using:&lt;br /&gt;
&lt;br /&gt;
$ mysql -u root&lt;br /&gt;
&lt;br /&gt;
If a password is required, use the extra switch -p:&lt;br /&gt;
$ mysql -u root -p&lt;br /&gt;
Enter password:&lt;br /&gt;
&lt;br /&gt;
Now that you are logged in, we create a database:&lt;br /&gt;
mysql&amp;gt; create database amarokdb;&lt;br /&gt;
Query OK, 1 row affected (0.00 sec)&lt;br /&gt;
&lt;br /&gt;
We allow user amarokuser to connect to the server from localhost using the password amarokpasswd:&lt;br /&gt;
mysql&amp;gt; grant usage on *.* to amarokuser@localhost identified by &amp;#039;amarokpasswd&amp;#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.00 sec)&lt;br /&gt;
&lt;br /&gt;
And finally we grant all privileges on the amarok database to this user:&lt;br /&gt;
mysql&amp;gt; grant all privileges on amarokdb.* to amarokuser@localhost ;&lt;br /&gt;
Query OK, 0 rows affected (0.00 sec)&lt;br /&gt;
&lt;br /&gt;
And that&amp;#039;s it. You can now check that you can connect to the MySQL server using this command:&lt;br /&gt;
$ mysql -u amarokuser -p&amp;#039;amarokpasswd&amp;#039; amarokdb&lt;br /&gt;
Your MySQL connection id is 12&lt;br /&gt;
Server version: 5.0.38-Ubuntu_0ubuntu1-log Ubuntu 7.04 distribution&lt;br /&gt;
&lt;br /&gt;
Type &amp;#039;help;&amp;#039; or &amp;#039;\h&amp;#039; for help. Type &amp;#039;\c&amp;#039; to clear the buffer.&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
== securing MYSQL and setting a Password ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/usr/bin/mysql_secure_installation&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Mysql Backup and Restore  ==&lt;br /&gt;
===List Databases===&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Login to server &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 mysql&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; List databases&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 show databases;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;List Tables in a database&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 use databasename&lt;br /&gt;
 show tables;&lt;br /&gt;
&lt;br /&gt;
===Bakcup a single database===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
done from bash - no need to log in to mysql&lt;br /&gt;
mysqldump -u root -ppassword sugarcrm &amp;gt; sugarcrm.sq&lt;br /&gt;
&lt;br /&gt;
syntax&lt;br /&gt;
&lt;br /&gt;
mysqldump -u root -p[root_password] [database_name] &amp;gt; dumpfilename.sql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
===Backup a single table===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mysqldump -u root -ppassword databasename table &amp;gt; sugarcrm.sq&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
===Backup Multiple Database===&lt;br /&gt;
* log into mysql&lt;br /&gt;
&lt;br /&gt;
 mysql -u root -pyourpassword&lt;br /&gt;
 mysql&amp;gt; show databases;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;this will give you a list of databases&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;For example, if you want to take backup of both sugarcrm and bugs database, execute the mysqldump as shown below:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
 mysqldump -u root -ptmppassword --databases bugs sugarcrm &amp;gt; bugs_sugarcrm.sql&lt;br /&gt;
&lt;br /&gt;
* Verify the bugs_sugarcrm.sql dumpfile contains both the database backup.&lt;br /&gt;
&lt;br /&gt;
 # grep -i &amp;quot;Current database:&amp;quot; /tmp/bugs_sugarcrm.sql&lt;br /&gt;
&lt;br /&gt;
 -- Current Database: `mysql`&lt;br /&gt;
&lt;br /&gt;
 -- Current Database: `sugarcrm`&lt;br /&gt;
&lt;br /&gt;
=== Backup all the databases:===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
The following example takes a backup of  all the database of the MySQL instance.&lt;br /&gt;
&lt;br /&gt;
# mysqldump -u root -ptmppassword --all-databases &amp;gt; /tmp/all-database.sql&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
=== Backup a specific table:===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
In this example, we backup only the accounts_contacts table from sugarcrm database.&lt;br /&gt;
&lt;br /&gt;
mysqldump -u root -ptmppassword sugarcrm accounts_contacts &amp;gt; /tmp/sugarcrm_accounts_contacts.sql &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;h1 class=&amp;quot;yellowbackground&amp;quot;&amp;gt;Script to import a CSV File into an existing Database&amp;lt;/h1&amp;gt; ==&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; the csv file has to be in that specific directory&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;The table has to already exist&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
mysql kartest &amp;lt;&amp;lt;EOF&lt;br /&gt;
truncate table songs;&lt;br /&gt;
load data infile &amp;#039;/var/lib/mysql-files/songs.csv&amp;#039;&lt;br /&gt;
into table songs&lt;br /&gt;
fields terminated by &amp;#039;|&amp;#039;&lt;br /&gt;
enclosed by &amp;#039;&amp;quot;&amp;#039;&lt;br /&gt;
lines terminated by &amp;#039;\n&amp;#039;&lt;br /&gt;
ignore 1 rows;&lt;br /&gt;
EOF&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Copy csv file to a dir and run script on server ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
fxcopy=&amp;quot;/mnt/c/Users/john/Dropbox/Shining Cabinet/My Stuff/sqlitedb&amp;quot;&lt;br /&gt;
scp -i ~/.ssh/linode &amp;quot;$fxcopy/filename.csv&amp;quot; 1.1.1.1:/var/lib/mysql-files/&lt;br /&gt;
sleep 4&lt;br /&gt;
ssh -i ~/.ssh/linode root@1.1.1.1 /var/www/scripts/import.sh&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Restore Database==&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; I used this to restore r512 the dumped .sql file in 2025 &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; I tried to restore it using phpmyadmin, but it did not work, got many errors. probably because it was a raw sql dump backup&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* log into mysql&lt;br /&gt;
 mysql&lt;br /&gt;
 use databasename&lt;br /&gt;
 source /path/to/sql/file.sql;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mysql -u username -p database &amp;lt; dump_file.sql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Set / Change Mysql Password ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Set / change / reset the MySQL root password on Ubuntu Linux. Enter the following lines in your terminal.&lt;br /&gt;
&lt;br /&gt;
Stop the MySQL Server.&lt;br /&gt;
sudo /etc/init.d/mysql stop&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
Start the mysqld configuration.&lt;br /&gt;
sudo mysqld --skip-grant-tables &amp;amp;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
Login to MySQL as root.&lt;br /&gt;
mysql -u root mysql&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
Replace YOURNEWPASSWORD with your new password!&lt;br /&gt;
UPDATE user SET Password=PASSWORD(&amp;#039;YOURNEWPASSWORD&amp;#039;) WHERE User=&amp;#039;root&amp;#039;; FLUSH PRIVILEGES; exit;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Reset mysql password  ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dpkg-reconfigure mysql-server-5.0&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
dpkg-reconfigure mysql-server-5.1&lt;br /&gt;
&lt;br /&gt;
Depending on which package you have installed.&lt;br /&gt;
&lt;br /&gt;
the will bring up the enter password screen for mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==  ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Import csv file into Php Myadmin Database  ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Structure has to match exactly or you will get an import error.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Invalid field count in csv input line 1&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make sure you count the fields. if there is 6 fileds (including the key) you must have 6 fields to import&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Fixing error connecting to database from AppSheet ==&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; The permission has to be fixed to the old version in mysql server &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
 ALTER USER &amp;#039;username&amp;#039;@&amp;#039;%&amp;#039; IDENTIFIED WITH mysql_native_password BY &amp;#039;password&amp;#039;;&lt;br /&gt;
 FLUSH PRIVILEGES;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
[[#MySql Commands My Fav|Back To Top]]-[[Main_Page| Home]]&lt;br /&gt;
[[Category:Mysql]]&lt;/div&gt;</summary>
		<author><name>Bacchas</name></author>
	</entry>
</feed>