Using the defines the user sets in wp-config:
mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
EDIT:
Since your script is outside the WordPress environment, what you want to do is initiate it before using the defines in wp-config.
require_once('./path/to/the/wp-config.php');
mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
Related Posts:
- Please explain how WordPress works with MySQL character set and collation at a low level
- Custom DB_COLLATE (collation) value not working on fresh install?
- Switching Databases in LocalHost
- how to encyrpt DB_PASSWORD in wp-config
- Can’t connect to MySQL server on ‘127.0.0.1’ (10061) (2003)
- MySQL SELECT increment counter
- Failed to connect to mysql at 127.0.0.1:3306 with user root access denied for user ‘root’@’localhost'(using password:YES)
- Using wpdb to connect to a separate database
- WordPress (MyISAM) database is slow, should I switch to InnoDB?
- WordPress Database lost auto increment
- wpdb->insert multiple record at once
- Is it possible to define two databases for one installation?
- Slow wp_term_relationships query
- How to use “TRUNCATE TABLE” MySQL statement?
- How To Make Connection To WordPress Data Base In A Plugin?
- WordPress for a very large website
- Bad Request (Invalid Hostname) on working server, database problem
- WooCommerce with thousands of products – site is very slow – optimize db queries? [closed]
- WooCommerce – Query for ordered products
- Error establishing a database connection – with Debug Data
- How to execute mulitple statement SQL queries using $wpdb->query?
- Database with mixed collation (utf8mb4 & utf8_general_ci)
- Query WordPress database by registered date and role
- Tons of Twitter rows in my database
- Set Display Name to first and last name (phpmyadmin SQL Query)
- Why can’t I swap a DB in a WP install? [closed]
- Migrating database / content of non-CMS site to WordPress
- Does WordPress ever need multiple databases?
- Why are no posts showing despite my apparently correct DB restoration?
- Select Multiple meta_value from WP DB; Single Query
- Delete all post meta except featured image Using SQL
- Is it possible to split database tables using HyperDB?
- Adding new row to wp_post table
- What happens if I overwrite the current wp_options table with a backup from a week ago?
- SQL Error wp_commentmeta – incorrect table definition
- WordPress database error – Error in SQL syntax – I can’t identify any error?
- CRUD operations using WordPress database API
- How do I get the posts within a certain year/date(with sql query)?
- How to Mirror WordPress database from Remote server to Local server
- Is MariaDB’s Aria storage engine suitable for WordPress?
- Slow queries constantly getting stuck on WordPress database of ~100,000 posts
- How do I query wp_options for expired transient pairs with MySQL commands?
- WordPress running SQL query to update database from form
- How to fix database error duplicate entry
- Migration: Copying database content to a different server
- Call to undefined function get_user_meta() – trying to access data in MySQL from custom fields
- How do I convert a MySQL database from utf8mb4 to utf8 encoding?
- Query multiple tables at once?
- Have working sql query… trying to adjust it to use $wpdb
- How to properly check if a table exists in WordPress Database using Show Tables Query
- creating new field on mysql
- Remove empty rows from the database
- Custom WordPress Table wpdb
- Why this query is not showing any result on wordpresss home page?
- Best practice to limit results in get_row()?
- Problem migrating to localhost
- Trouble running $wpdb->query() with last_insert_id
- SQL query to set posts in bulk based on the post content
- How can I detect right db type?
- Changing order of db results when encoding to JSON
- Second ezSQL initialization for MSSQL
- Fetch a single row from a custom table for to a given ID
- Database create or redirect
- Can two domains use the same database?
- How to escape percentage sign(%) in sql query with $wpdb->prepare?
- Link multiple user databases together?
- Recovery – Restore Database after moving folder location locally
- I wanted to Know that how can I give ingore to 0000-00-00 in my config file
- Set a cron job to delete a specific database table table every midnight
- Error establishing a database connection – WordPress setup, everything else is working
- How to import products in host instead of database on wordpress?
- I would like some help wth an SQL query to link posts with categories
- Where is the HTML-handler part in the wpdb class?
- next comment id number wordpress
- Search and Replace in Windows XAMPP site
- How can i syn wordpress user table with a stand-alone php script?
- How can I get $wpdb to show MySQL warnings?
- Merging development site with live site
- The MySQL Connection could not be established., before it was joomla but i have change it into worpress
- Cloned site not connecting to database – MAMP
- How to extract some part of WordPress full source code
- Does WordPress Support Using Named Pipes on the Windows Operating System?
- Missing latest posts and options after DB migration via phpMyAdmin
- Check if a database is well installed
- live site do not update after importing sql database
- How do i get value from wp_postmeta?
- “MySQL server has gone away” since update to 3.8
- Why are my WordPress post queries so slow?
- featured image not showing up with mysql_connect
- MySQL Database User: Which Privileges are needed?
- Import Excel (or csv) Table with user-data as subscribers to wordpress
- Print output of Table Creation
- DB access blocked when initializing WP externally
- SQL query : Select a thumbnail for a media
- ERROR: “Table Prefix” must not be empty
- Custom wordpress SQL statement for a website
- SQL Query to get post_id from wp_posts and and meta_key(s) from wp_postmeta
- wp-config was suddenly updated
- How to find fresh (last modified) and sql backup?
- Uploading to WordPress Database